home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 7: Sunsite / Linux Cubed Series 7 - Sunsite Vol 1.iso / system / network / samba / patches / samba-1.9 / samba-1
Text File  |  1996-02-28  |  147KB  |  5,237 lines

  1. diff -u -r --new-file last-version/docs/DOMAIN.txt samba-1.9.16alpha1/docs/DOMAIN.txt
  2. --- last-version/docs/DOMAIN.txt    Mon Jan 15 19:58:59 1996
  3. +++ samba-1.9.16alpha1/docs/DOMAIN.txt    Thu Feb 22 11:18:54 1996
  4. @@ -6,6 +6,9 @@
  5.  administration. Support for these kind of things should be added
  6.  sometime in the future.
  7.  
  8. +The domain support only works for WfWg and Win95 clients. Support for
  9. +NT and OS/2 clients is still being worked on.
  10. +
  11.  Using these features you can make your clients verify their logon via
  12.  the Samba server and make clients run a batch file when they logon to
  13.  the network. The latter is particularly useful.
  14. @@ -56,4 +59,10 @@
  15.  6) you will probabaly find that your clients automatically mount the
  16.  \\SERVER\NETLOGON share as drive z: while logging in. You can put some
  17.  useful programs there to execute from the batch files.
  18. +
  19. +
  20. +NOTE: You must be using "security = user" or "security = server" for
  21. +domain logons to work correctly. Share level security won't work
  22. +correctly.
  23. +
  24.  
  25. diff -u -r --new-file last-version/docs/INSTALL.txt samba-1.9.16alpha1/docs/INSTALL.txt
  26. --- last-version/docs/INSTALL.txt    Mon Nov 27 10:55:51 1995
  27. +++ samba-1.9.16alpha1/docs/INSTALL.txt    Sat Feb 24 18:57:55 1996
  28. @@ -89,6 +89,9 @@
  29.  
  30.  Step 5a. Starting from inetd.conf
  31.  
  32. +NOTE; The following will be different if you use NIS or NIS+ to
  33. +distributed services maps.
  34. +
  35.  Look at your /etc/services. What is defined at port 139/tcp. If
  36.  nothing is defined then add a line like this:
  37.  
  38. diff -u -r --new-file last-version/docs/MIRRORS samba-1.9.16alpha1/docs/MIRRORS
  39. --- last-version/docs/MIRRORS    Mon Nov 27 10:55:51 1995
  40. +++ samba-1.9.16alpha1/docs/MIRRORS    Tue Feb 20 20:41:42 1996
  41. @@ -3,12 +3,15 @@
  42.  
  43.  Mirror sites include:
  44.  
  45. +
  46.  ftp://src.doc.ic.ac.uk/packages/samba
  47. -ftp://ftp.demon.co.uk/pub/unix/samba
  48. -ftp://sunsite.unc.edu/pub/Linux/system/Network/Samba/
  49. +ftp://ftp.warwick.ac.uk/pub/linux/sunsite.unc-mirror/system/Network/samba
  50. +ftp://sunsite.unc.edu/pub/Linux/system/Network/samba/
  51.  ftp://ftp.choc.apana.org.au/pub/samba
  52.  ftp://ftp.uni-trier.de/pub/unix/network/samba/
  53.  ftp://ftp.spectrum.titan.com/pub/samba
  54. +ftp://ftp.demon.co.uk/pub/unix/unix/samba
  55. +ftp://sunsite.mff.cuni.cz/Net/Protocols/Samba
  56.  
  57.  There are several others. Give archie a try.
  58.  
  59. diff -u -r --new-file last-version/docs/README.OS2 samba-1.9.16alpha1/docs/README.OS2
  60. --- last-version/docs/README.OS2    Thu Jan  1 10:00:00 1970
  61. +++ samba-1.9.16alpha1/docs/README.OS2    Tue Feb 20 11:44:07 1996
  62. @@ -0,0 +1,81 @@
  63. +Samba 1.9.15p8 for OS/2  :  REQUIRES emx 0.9b.
  64. +
  65. +
  66. +Please read the file README, which contains general information about
  67. +the configuration and use of Samba.
  68. +
  69. +
  70. +Notes specific to OS/2 port:
  71. +============================
  72. +
  73. +Filenames have been shortened to 8.3 in case anyone is using FAT.
  74. +Files affected are:
  75. +smb.conf  -> smb.cfg          smbclient -> smbclnt.exe
  76. +smbstatus -> smbstat.exe      nmblookup -> nmblook.exe
  77. +
  78. +As I only use HPFS, I can't guarantee this will work on FAT systems,
  79. +although I have tried to stick to 8.3 filenames.  I have noticed some
  80. +temporary files being created with long filenames by smbd when I tried
  81. +printing (which does not work yet anyway).  nmbd will not be able to
  82. +create browse lists on FAT systems, as it uses temporary files with
  83. +long file names.
  84. +
  85. +smb.cfg should be in the directory smbd is started from.  The path to
  86. +smb.cfg is a compile time option, so if you are compiling from source
  87. +you can set this to an absolute path to remove this restriction.
  88. +
  89. +User home directories not supported.  This doesn't make much sense on
  90. +OS/2.  I haven't actually disabled anything, so if you try setting
  91. +this up, behaivour is undefined.
  92. +
  93. +Password support is incomplete (I have found a crypt() routine, but 
  94. +lack of passwd file support in the EMX libraries make support difficult
  95. +without major changes).
  96. +
  97. +Printing does not appear to be working.  OS/2's lpq gives output in a
  98. +different format than the versions of lpq already supported by samba.
  99. +This will be easy to accomodate, but there is not much point until I can
  100. +get lpr working properly.
  101. +
  102. +
  103. +
  104. +Source is available from the Samba WWW site :
  105. +
  106. +http://lake.canberra.edu.au/pub/samba/
  107. +
  108. +EMX 0.9b is available from hobbes.nmsu.edu, ftp.cdrom.com, ftp.leo.org and
  109. +other OS/2 FTP sites.  emxrt.zip contains the required libraries.
  110. +
  111. +Bugs:
  112. +=====
  113. +
  114. +Known problems:
  115. +===============
  116. +
  117. +Printing does not work.  I have tried using REXX scripts with path info
  118. +built in, and watched the processes startup properly but nothing comes
  119. +out of the printer (remote via lpr in this case).
  120. +If you can get it going, please let me know how you did it.
  121. +
  122. +The output from OS/2's lpq.exe is not understood by smbd, so all querys
  123. +about the print queue say it is empty.  Printing doesn't work anyway,
  124. +so I have not attempted to fix this yet.
  125. +
  126. +Temporary files are created with long filenames (when printing, and updating
  127. +browse list)
  128. +
  129. +Bug reports for the OS/2 port should be sent to Jason Rumney <jasonr@pec.co.nz>.
  130. +
  131. +Change log:
  132. +===========
  133. +
  134. +Changes from release 1 to release 2.
  135. +
  136. +nmblookup (nmblook.exe) is included, and works.
  137. +
  138. +An attempt at password support was made using the gnuufc crypt routines,
  139. +but then I found that a lot of functions in the EMX libraries to do with
  140. +passwd files don't actually do anything.
  141. +
  142. +Browse lists should now work if you use HPFS and set your lock directory
  143. +to an absolute pathname.
  144. diff -u -r --new-file last-version/docs/Support.txt samba-1.9.16alpha1/docs/Support.txt
  145. --- last-version/docs/Support.txt    Mon Jan 15 12:45:44 1996
  146. +++ samba-1.9.16alpha1/docs/Support.txt    Wed Feb 28 14:42:56 1996
  147. @@ -330,3 +330,31 @@
  148.  -----------------------------------------------------------------------
  149.  
  150.  
  151. +-----------------------------------------------------------------------
  152. +MELBOURNE - AUSTRALIA
  153. +
  154. +Michael Ciavarella
  155. +Cybersoruce Pty Ltd.
  156. +8/140 Queen Street
  157. +Melbourne  VIC 3000
  158. +Phone:  +61-3-9642-5997
  159. +Fax:    +61-3-9642-5998
  160. +Email:  mikec@cyber.com.au
  161. +WWW:    http://www.cyber.com.au
  162. +
  163. +Cybersource specialises in TCP/IP network integration and Open Systems
  164. +administration.  Cybersource is an Australian-owned and operated 
  165. +company, with clients including some of Australia's largest financial,
  166. +petrochemical and state government organisations.  
  167. +-----------------------------------------------------------------------
  168. +
  169. +-----------------------------------------------------------------------
  170. +SOUTHERN CALIFORNIA - USA
  171. +
  172. +Michael St. Laurent
  173. +Serving Los Angeles and Orange Counties.  Please contact via email.
  174. +rowl@earthlink.net
  175. +Michael St. Laurent
  176. +Hartwell Corporation
  177. +-----------------------------------------------------------------------
  178. +
  179. diff -u -r --new-file last-version/docs/nmbd.8 samba-1.9.16alpha1/docs/nmbd.8
  180. --- last-version/docs/nmbd.8    Mon Nov 27 10:55:52 1995
  181. +++ samba-1.9.16alpha1/docs/nmbd.8    Sun Feb 18 18:01:38 1996
  182. @@ -28,12 +28,15 @@
  183.  ] [
  184.  .B -l
  185.  .I log basename
  186. -]
  187. +] [
  188.  .B -n
  189.  .I netbios name
  190.  ] [
  191.  .B -p
  192.  .I port number
  193. +] [
  194. +.B -s
  195. +.I config file name
  196.  ]
  197.  
  198.  .SH DESCRIPTION
  199. diff -u -r --new-file last-version/docs/smb.conf.5 samba-1.9.16alpha1/docs/smb.conf.5
  200. --- last-version/docs/smb.conf.5    Mon Jan 15 20:31:25 1996
  201. +++ samba-1.9.16alpha1/docs/smb.conf.5    Sat Feb 24 18:56:19 1996
  202. @@ -35,7 +35,7 @@
  203.  Any line beginning with a semicolon is ignored, as are lines containing 
  204.  only whitespace.
  205.  
  206. -Any line ending in a \ is "continued" on the next line in the
  207. +Any line ending in a \\ is "continued" on the next line in the
  208.  customary unix fashion.
  209.  
  210.  The values following the equals sign in parameters are all either a string
  211. @@ -246,9 +246,13 @@
  212.  
  213.  %u = user name of the current service, if any
  214.  
  215. +%g = primary group name of %u
  216. +
  217.  %U = session user name (the user name that the client wanted, not
  218.  necessarily the same as the one they got)
  219.  
  220. +%G = primary group name of %U
  221. +
  222.  %H = the home directory of the user given by %u
  223.  
  224.  %v = the Samba version
  225. @@ -483,8 +487,12 @@
  226.  
  227.  locking
  228.  
  229. +lppause command
  230. +
  231.  lpq command
  232.  
  233. +lpresume command
  234. +
  235.  lprm command
  236.  
  237.  magic output
  238. @@ -1120,6 +1128,34 @@
  239.  .SS log level (G)
  240.  see "debug level"
  241.  
  242. +.SS lppause command (S)
  243. +This parameter specifies the command to be executed on the server host in
  244. +order to stop printing or spooling a specific print job.
  245. +
  246. +This command should be a program or script which takes a printer name and
  247. +job number to pause the print job. Currently I don't know of any print
  248. +spooler system that can do this with a simple option, except for the PPR
  249. +system from Trinity College (ppr\-dist.trincoll.edu/pub/ppr). One way
  250. +of implementing this is by using job priorities, where jobs having a too
  251. +low priority wont be sent to the printer. See also the lppause command.
  252. +
  253. +If a %p is given then the printername is put in it's place. A %j is
  254. +replaced with the job number (an integer).
  255. +On HPUX (see printing=hpux), if the -p%p option is added to the lpq
  256. +command, the job will show up with the correct status, i.e. if the job
  257. +priority is lower than the set fence priority it will have the PAUSED
  258. +status, whereas if the priority is equal or higher it will have the
  259. +SPOOLED or PRINTING status.
  260. +
  261. +Note that it is good practice to include the absolute path in the lppause
  262. +command as the PATH may not be available to the server.
  263. +
  264. +.B Default:
  265. +        Currently no default value is given to this string
  266. +
  267. +.B Example for HPUX:
  268. +        lppause command = /usr/bin/lpalt %p-%j -p0
  269. +
  270.  .SS lpq cache time (G)
  271.  
  272.  This controls how long lpq info will be cached for to prevent the lpq
  273. @@ -1173,6 +1209,25 @@
  274.  .B Example:
  275.       lpq command = /usr/bin/lpq %p
  276.  
  277. +.SS lpresume command (S)
  278. +This parameter specifies the command to be executed on the server host in
  279. +order to restart or continue printing or spooling a specific print job.
  280. +
  281. +This command should be a program or script which takes a printer name and
  282. +job number to resume the print job. See also the lppause command.
  283. +
  284. +If a %p is given then the printername is put in it's place. A %j is
  285. +replaced with the job number (an integer).
  286. +
  287. +Note that it is good practice to include the absolute path in the lpresume
  288. +command as the PATH may not be available to the server.
  289. +
  290. +.B Default:
  291. +        Currently no default value is given to this string
  292. +
  293. +.B Example for HPUX:
  294. +        lpresume command = /usr/bin/lpalt %p-%j -p2
  295. +
  296.  .SS lprm command (S)
  297.  This parameter specifies the command to be executed on the server host in
  298.  order to delete a print job.
  299. @@ -1196,7 +1251,7 @@
  300.  .B Example 1:
  301.       lprm command = /usr/bin/lprm -P%p %j
  302.  
  303. -.B Example 1:
  304. +.B Example 2:
  305.       lprm command = /usr/bin/cancel %p-%j
  306.  
  307.  .SS magic output (S)
  308. @@ -1324,7 +1379,7 @@
  309.  .B Example:
  310.       mangling char = ^
  311.  
  312. -.SS max log file (G)
  313. +.SS max log size (G)
  314.  
  315.  This option (an integer in kilobytes) specifies the max size the log
  316.  file should grow to. Samba periodically checks the size and if it is
  317. @@ -1485,7 +1540,7 @@
  318.  
  319.  For the really adventurous, try something like this:
  320.  
  321. -message command = csh -c 'csh < %s |& /usr/local/samba/smbclient \
  322. +message command = csh -c 'csh < %s |& /usr/local/samba/smbclient \\
  323.                    -M %m; rm %s' &
  324.  
  325.  this would execute the command as a script on the server, then give
  326. diff -u -r --new-file last-version/docs/smbclient.1 samba-1.9.16alpha1/docs/smbclient.1
  327. --- last-version/docs/smbclient.1    Mon Nov 27 10:55:54 1995
  328. +++ samba-1.9.16alpha1/docs/smbclient.1    Tue Feb 20 12:11:35 1996
  329. @@ -41,6 +41,10 @@
  330.  ] [
  331.  .B -p
  332.  .I port number
  333. +.B -T
  334. +.I tar options
  335. +.B -D
  336. +.I initial directory
  337.  ]
  338.  .SH DESCRIPTION
  339.  This program is part of the Samba suite.
  340. @@ -54,14 +58,6 @@
  341.  server to the local machine, putting files from the local machine to
  342.  the server, retrieving directory information from the server and so on.
  343.  
  344. -NOTE: Ricky Poulten (poultenr@logica.co.uk) has written a "tar"
  345. -extension to smbclient that allows you to back up and restore your
  346. -lan-manager compatible network using smbclient.
  347. -
  348. -You can fetch the tar extension from the "contributed" section on
  349. -nimbus. ftp://nimbus.anu.edu.au/pub/tridge/samba/contributed/
  350. -
  351. -
  352.  .SH OPTIONS
  353.  .B servicename
  354.  .RS 3
  355. @@ -340,6 +336,97 @@
  356.  hence the default.
  357.  
  358.  This parameter is not normally specified.
  359. +
  360. +.B -T
  361. +.I tar options
  362. +.RS3 
  363. +
  364. +where tar options are one or more of c,x,I,X,b,g,N or a; used as:
  365. +.LP
  366. +smbclient 
  367. +.B "\\\\\\\\server\\\\share"
  368. +\-TcxIXbgNa
  369. +[
  370. +.IR blocksize
  371. +]
  372. +[
  373. +.IR newer-file
  374. +]
  375. +.IR tarfile
  376. +[
  377. +.IR filenames....
  378. +]
  379. +
  380. +.RS3
  381. +.B c
  382. +Create a tar file on UNIX. Must be followed by the name of a tar file,
  383. +tape device or "-" for standard output. (May be useful to set debugging
  384. +low (-d0)) to avoid corrupting your tar file if using "-"). Mutually
  385. +exclusive with the x flag.
  386. +
  387. +.B x
  388. +Extract (restore) a local tar file back to a share. Unless the -D
  389. +option is given, the tar files will be restored from the top level of
  390. +the share. Must be followed by the name of the tar file, device or "-"
  391. +for standard input. Mutually exclusive with the c flag.
  392. +
  393. +.B I
  394. +Include files and directories. Is the default behaviour when
  395. +.IR filenames
  396. +are specified above. Causes tar files to be included in an extract or create
  397. +(and therefore everything else to be excluded). See example below.
  398. +Filename globbing does not work for included files for extractions (yet).
  399. +
  400. +.B X
  401. +Exclude files and directories. Causes tar files to be excluded from
  402. +an extract or create. See example below.
  403. +Filename globbing does not work for excluded files (yet).
  404. +
  405. +.B b
  406. +Blocksize. Must be followed by a valid (greater than zero) blocksize.
  407. +Causes tar file to be written out in blocksize*TBLOCK (usually 512 byte)
  408. +blocks.
  409. +
  410. +.B g
  411. +Incremental. Only back up files that have the archive bit set. Useful
  412. +only with the c flag.
  413. +
  414. +.B N
  415. +Newer than. Must be followed by the name of a file whose date is
  416. +compared against files found on the share during a create. Only files
  417. +newer than the file specified are backed up to the tar file. Useful
  418. +only with the c flag.
  419. +
  420. +.B a
  421. +Set archive bit. Causes the archive bit to be reset when a file is backed
  422. +up. Useful with the g (and c) flags.
  423. +.LP
  424. +
  425. +.B Examples
  426. +
  427. +smbclient \\\\mypc\\myshare "" -N -Tx backup.tar
  428. +
  429. +Restore from tar file backup.tar into myshare on mypc (no password on share).
  430. +
  431. +smbclient \\\\mypc\\myshare "" -N -TXx backup.tar users/docs
  432. +
  433. +Restore everything except users/docs
  434. +
  435. +smbclient \\\\mypc\\myshare "" -N -Tc backup.tar users/docs
  436. +
  437. +Create a tar file of the files beneath users/docs.
  438. +
  439. +.RE
  440. +
  441. +.B -D
  442. +.I initial directory
  443. +
  444. +.RS3 
  445. +
  446. +Change to initial directory before starting. Probably only of any use
  447. +with the tar (\-T) option.
  448. +
  449. +
  450.  .RE
  451.  
  452.  .SH OPERATIONS
  453. @@ -894,6 +981,72 @@
  454.  .RE
  455.  .RE
  456.  
  457. +.B tar
  458. +.RS 3
  459. +.B Parameters:
  460. +.RS 3
  461. +.I <c|x>[IXbgNa]
  462. +
  463. +.RE
  464. +.B Description:
  465. +.RS 3
  466. +Performs a tar operation - see -T command line option above. Behaviour
  467. +may be affected by the
  468. +.B tarmode
  469. +command (see below). Using the g (incremental) and N (newer) will affect
  470. +tarmode settings. Note that using the "-" option with tar x may not
  471. +work - use the command line option instead.
  472. +.RE
  473. +.RE
  474. +
  475. +.B blocksize
  476. +.RS 3
  477. +.B Parameters
  478. +.RS 3
  479. +.I <blocksize>
  480. +
  481. +.RE
  482. +.B Description
  483. +.RS 3
  484. +Blocksize. Must be followed by a valid (greater than zero) blocksize.
  485. +Causes tar file to be written out in blocksize*TBLOCK (usually 512 byte)
  486. +blocks.
  487. +.RE
  488. +.RE
  489. +
  490. +.B tarmode
  491. +.RS 3
  492. +.B Parameters
  493. +.RS 3
  494. +.I <full|inc|reset|noreset>
  495. +
  496. +.RE
  497. +.B Description
  498. +.RS 3
  499. +Changes tar's behaviour with regard to archive bits. In full mode,
  500. +tar will back up everything regardless of the archive bit setting (this
  501. +is the default mode). In incremental mode, tar will only back up files
  502. +with the archive bit set. In reset mode, tar will reset the archive bit
  503. +on all files it backs up (implies read/write share).
  504. +.RE
  505. +.RE
  506. +
  507. +.B setmode
  508. +.RS 3
  509. +.B Parameters
  510. +.RS 3
  511. +.I <filename> <perm=[+|-]rsha>
  512. +
  513. +.RE
  514. +.B Description
  515. +.RS 3
  516. +A version of the DOS attrib command to set file permissions. For example,
  517. +
  518. +setmode myfile +r
  519. +
  520. +would make myfile read only.
  521. +.RE
  522. +.RE
  523.  
  524.  .SH NOTES
  525.  Some servers are fussy about the case of supplied usernames, passwords, share
  526. diff -u -r --new-file last-version/docs/smbtar.1 samba-1.9.16alpha1/docs/smbtar.1
  527. --- last-version/docs/smbtar.1    Mon Nov 27 10:55:54 1995
  528. +++ samba-1.9.16alpha1/docs/smbtar.1    Tue Feb 20 12:11:35 1996
  529. @@ -1,4 +1,4 @@
  530. -.TH SMBTAR 1 6/10/1994 smbtar smbtar
  531. +.TH SMBTAR 1 18/2/96 smbtar smbtar
  532.  .SH NAME
  533.  smbtar \- shell script for backing up SMB shares directly to UNIX tape drive
  534.  .SH SYNOPSIS
  535. @@ -11,6 +11,10 @@
  536.  .B [ \-x
  537.  .I service
  538.  .B ]
  539. +.B [ \-X ]
  540. +.B [ \-d
  541. +.I directory
  542. +.B ]
  543.  .B [ \-u
  544.  .I user
  545.  .B ]
  546. @@ -20,12 +24,14 @@
  547.  .B [ \-b
  548.  .I blocksize
  549.  .B ]
  550. -.B [ \-n
  551. +.B [ \-N
  552.  .I filename
  553.  .B ]
  554.  .B [ \-i ]
  555.  .B [ \-r ]
  556.  .B [ \-l ]
  557. +.B [ \-v ]
  558. +.I filenames...
  559.  
  560.  .SH DESCRIPTION
  561.  This program is an extension to the Samba suite.
  562. @@ -48,6 +54,26 @@
  563.  .I backup.
  564.  .RE
  565.  
  566. +.B \-X
  567. +.RS 3
  568. +Exclude mode. Exclude
  569. +.I filenames...
  570. +from tar create or restore.
  571. +.RE
  572. +
  573. +.B \-d
  574. +.I directory
  575. +.RS 3
  576. +Change to initial
  577. +.I directory
  578. +before restoring / backing up files.
  579. +.RE
  580. +
  581. +.B \-v
  582. +.RS 3
  583. +Verbose mode.
  584. +.RE
  585. +
  586.  .B \-p
  587.  .I password
  588.  
  589. @@ -75,20 +101,17 @@
  590.  Blocking factor. Defaults to 20. See tar(1) for a fuller explanation.
  591.  .RE
  592.  
  593. -.B \-n
  594. +.B \-N
  595.  .I filename
  596.  .RS 3
  597.  Backup only files newer than filename. Could be used (for example) on a log
  598. -file to implement incremental backups. This flag should not be used with the
  599. -\-i flag, the results may not be sensible.
  600. +file to implement incremental backups.
  601.  .RE
  602.  
  603.  .B \-i
  604.  .RS 3
  605.  Incremental mode; tar files are only backed up if they have the
  606.  archive bit set. The archive bit is reset after each file is read.
  607. -This flag should not be used with the \-n flag, the results may not be
  608. -sensible. 
  609.  .RE
  610.  
  611.  .B \-r
  612. @@ -106,9 +129,8 @@
  613.  be overidden with the -t option.
  614.  
  615.  .SH BUGS
  616. -The shell script has only been tested under solaris 2. It's
  617. -not very portable and should probably be customized to a particular
  618. -site's setup.
  619. +The smbtar script has different options from ordinary tar and tar
  620. +called from smbclient.
  621.  
  622.  .SH CAVEATS
  623.  Sites that are more careful about security may not like the way
  624. @@ -116,7 +138,7 @@
  625.  should work on file lists.
  626.  
  627.  .SH VERSION
  628. -This man page is correct for version 1.9.02 of the Samba suite.
  629. +This man page is correct for version 1.9.15p8 of the Samba suite.
  630.  
  631.  .SH SEE ALSO
  632.  .B smbclient
  633. @@ -134,7 +156,9 @@
  634.  of the Source for this project.
  635.  
  636.  Ricky Poulten (poultenr@logica.co.uk) wrote the tar extension and this
  637. -man page.
  638. +man page. The smbtar script was heavily rewritten and improved by
  639. +Martin Kraemer <Martin.Kraemer@mch.sni.de>. Many thanks to everyone
  640. +who suggested extensions, improvements, bug fixes, etc.
  641.  
  642.  See
  643.  .B smb.conf
  644. diff -u -r --new-file last-version/examples/misc/extra_smbstatus samba-1.9.16alpha1/examples/misc/extra_smbstatus
  645. --- last-version/examples/misc/extra_smbstatus    Thu Jan  1 10:00:00 1970
  646. +++ samba-1.9.16alpha1/examples/misc/extra_smbstatus    Thu Feb 22 12:05:00 1996
  647. @@ -0,0 +1,47 @@
  648. +Here's something that Paul Blackman sent me that may be useful:
  649. +
  650. +-------------------
  651. +I created this script to do a few things that smbstatus doesn't at the
  652. +moment.  Perhaps you might want to include these.  Sorry I haven't
  653. +added things at source level, script was quick&easy.
  654. +
  655. +*******
  656. +#!/bin/csh
  657. +if ($1 == "-p") then
  658. +  smbstatus -p |sort -u
  659. +else if ($1 == "-c") then
  660. +  echo There are `smbstatus -p |sort -u |grep -n -v z |grep -c :` unique
  661. +smbd processes running.
  662. + else if ($1 == "-l") then
  663. +  echo `date '+ %d/%m/%y %H:%M:%S'` `smbstatus -p |sort -u |grep -n -v z
  664. +|grep -c :` >>$2
  665. +else
  666. +  smbstatus |sort +3 -4 -u
  667. +endif
  668. +******
  669. +
  670. +The '-p' option was just to show unique PIDs.
  671. +
  672. +The more important ones are the '-c' and '-l' options '-c' just counts
  673. +the number of unique smbd's, While '-l' logs this count with date and
  674. +time to a log file specified on the command line.  I'm using '-l' at
  675. +the moment with cron to give me an idea of usage/max connections etc.
  676. +I was also thinking of doing a log for individual/specified services.
  677. +
  678. +The default (last) option was to show unique PIDs with user names.
  679. +Unfortunately this still lists all file locks etc.  This would be
  680. +better with a 'no locked files' option from smbstatus (or is there one
  681. +that I didn't see)
  682. +
  683. +Cheers,
  684. +~^ MIME OK ^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~
  685. +    o        |  Paul Blackman                  ictinus@lake.canberra.edu.au
  686. +        o    |  Co-operative Research              ------------------------
  687. +   o  _      |  Centre For Freshwater Ecology.        Ph.  (Aus) 06 2012518
  688. +  -- (") o   |  University of Canberra, Australia.       Fax. "  06 2015038
  689. +    \_|_--   |~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  690. +      |      |  "Spend a little love and get high"
  691. +    _/ \_    |                                              - Lenny Kravitz
  692. +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  693. +~~~~ SAMBA Web Pages: http://samba.canberra.edu.au/pub/samba/samba.html ~~~~~
  694. +
  695. diff -u -r --new-file last-version/examples/misc/wall.perl samba-1.9.16alpha1/examples/misc/wall.perl
  696. --- last-version/examples/misc/wall.perl    Thu Jan  1 10:00:00 1970
  697. +++ samba-1.9.16alpha1/examples/misc/wall.perl    Sat Feb 24 18:54:44 1996
  698. @@ -0,0 +1,45 @@
  699. +#!/usr/local/bin/perl
  700. +# 
  701. +#@(#) smb-wall.pl Description:
  702. +#@(#) A perl script which allows you to announce whatever you choose to
  703. +#@(#) every PC client currently connected to a Samba Server...
  704. +#@(#) ...using "smbclient -M" message to winpopup service.
  705. +#@(#) Default usage is to message every connected PC.
  706. +#@(#) Alternate usage is to message every pc on the argument list.
  707. +#@(#)    Hacked up by Keith Farrar <farrar@parc.xerox.com>
  708. +#
  709. +#=============================================================================
  710. +$smbstatus = "/usr/local/bin/smbstatus";
  711. +$smbclient = "/usr/local/bin/smbclient";
  712. +
  713. +print STDOUT "\nEnter message for Samba clients of this host\n";
  714. +print STDOUT "(terminated with single '.' or end of file):\n";
  715. +
  716. +while ( <STDIN> ) {
  717. +    /^\.$/ && last;
  718. +    push(@message,  $_);
  719. +}
  720. +
  721. +if ( $ARGV[0] ne "" ) {
  722. +    $debug && print STDOUT "Was given args: \n\t @ARGV\n";
  723. +    foreach $client ( @ARGV ) {
  724. +        $pcclient{$client} = $client;
  725. +    }
  726. +} else {
  727. +    open( PCLIST, "$smbstatus | /bin/awk '/^[a-z]/ {print $5}' | /bin/sort | /bin/uniq|");
  728. +    while ( <PCLIST> ) {
  729. +        /^[a-z]+[a-z0-9A-Z-_]+.+/ || next;
  730. +        ($share, $user, $group, $pid, $client, @junk) = split;
  731. +        $pcclient{$client} = $client;
  732. +    }
  733. +    close(PCLIST);
  734. +}
  735. +
  736. +foreach $pc ( keys(%pcclient) ) {
  737. +    print STDOUT "Sending message ";
  738. +    $debug && print STDOUT " <@message> \n";
  739. +    print STDOUT "To <$pc>\n";
  740. +    open(SENDMSG,"|$smbclient -M $pc") || next;
  741. +    print SENDMSG @message;
  742. +    close(SENDMSG);
  743. +}
  744. diff -u -r --new-file last-version/source/Makefile samba-1.9.16alpha1/source/Makefile
  745. --- last-version/source/Makefile    Mon Jan 15 19:02:02 1996
  746. +++ samba-1.9.16alpha1/source/Makefile    Thu Feb 29 00:12:08 1996
  747. @@ -35,8 +35,9 @@
  748.  SHELL = /bin/sh
  749.  
  750.  # The following can be useful for compiling on multiple architectures
  751. -srcdir=.
  752. -VPATH=$(srcdir)
  753. +# just uncommment them putting the right directory in.
  754. +# srcdir=./
  755. +# VPATH=$(srcdir)
  756.  
  757.  # set these to where to find various files
  758.  # These can be overridden by command line switches (see smbd(8))
  759. @@ -165,6 +166,16 @@
  760.  # FLAGSM = -DLINUX
  761.  # LIBSM = 
  762.  
  763. +# Use this for Linux with shadow passwords and quota
  764. +# contributed by xeno@mix.hive.no
  765. +# Tested on the 1.3.57 kernel and ext2fs filesystem.
  766. +# Notes:
  767. +# /usr/include/sys/quota.h must be a symlink to /usr/include/linux/quota.h
  768. +# The directory quota here must be a symlink to your quota package.
  769. +# I just do 'ln -sf /usr/src/quota-1.50 quota' in this directory to get it to work.
  770. +# FLAGSM = -O3 -m486 -DLINUX -DSHADOW_PWD -DQUOTAS
  771. +# LIBSM = -lshadow
  772. +
  773.  
  774.  # This is for SUNOS5 (also known as Solaris 2)
  775.  # contributed by Andrew.Tridgell@anu.edu.au
  776. @@ -261,6 +272,11 @@
  777.  # FLAGSM = -DHPUX -Aa -D_HPUX_SOURCE -D_POSIX_SOURCE -DDFS_AUTH -D_REENTRANT -I/usr/include/reentrant
  778.  # LIBSM = -ldce -lM -lc_r
  779.  
  780. +# HP-UX 10.x Trusted System
  781. +# Contributed by David-Michael Lincke (dlincke@sgcl1.unisg.ch)
  782. +# FLAGSM = +O3 -Ae -DHPUX -DHPUX_10_TRUSTED
  783. +# LIBSM = -lsec
  784. +
  785.  
  786.  # This is for SGI.
  787.  # contributed by lpc@solomon.technet.sg (Michael Chua)
  788. @@ -358,6 +374,8 @@
  789.  
  790.  # Use this for SCO OpenServer 5 with TCB passwords (default).
  791.  # contributed by Scott Michel <scottm@intime.intime.com>
  792. +# you may also like to add the -dy switch (recommended by Marnus van 
  793. +# Niekerk, mvn@pixie.co.za)
  794.  # CC     = cc -Xc
  795.  # FLAGSM = -DSCO -DSecureWare -DEVEREST -DUSE_MMAP
  796.  # LIBSM  = -lprot -lcurses -lcrypt -lsocket -lPW -lm -lx -lc_s -lc
  797. @@ -440,6 +458,12 @@
  798.  # LIBSM = -Zexe -lsocket
  799.  
  800.  
  801. +# This is for LYNX 2.3.0 (gcc v2.6)
  802. +# Contributed by woelfel@hpe.fzk.de (Manfred Woelfel)
  803. +# FLAGSM = -DLYNX -DUFC_CRYPT -mposix
  804. +# LIBSM = -lbsd
  805. +
  806. +
  807.  ######################################################################
  808.  # DON'T EDIT BELOW THIS LINE
  809.  ######################################################################
  810. @@ -459,7 +483,7 @@
  811.  all : CHECK $(PROGS)
  812.  
  813.  CHECK :
  814. -    @$(SHELL) $(srcdir)/checkos.sh $(FLAGSM)
  815. +    @$(SHELL) $(srcdir)checkos.sh $(FLAGSM)
  816.      @echo "Using CFLAGS = $(CFLAGS)"
  817.      @echo "Using LIBS = $(LIBS)"
  818.  
  819. @@ -479,7 +503,7 @@
  820.  
  821.  .c.o: $(INCLUDES)
  822.      @echo Compiling $*.c
  823. -    @$(CC) $(CFLAGS) -c $(srcdir)/$*.c
  824. +    @$(CC) $(CFLAGS) -c $(srcdir)$*.c
  825.  
  826.  smbd: server.o $(SMBDOBJ)
  827.      @echo Linking smbd
  828. @@ -497,9 +521,9 @@
  829.      @echo Linking nmbd
  830.      @$(CC) $(CFLAGS) -o nmbd nameserv.o nmblib.o nmbsync.o $(PARAMOBJ) $(LIBS)
  831.  
  832. -smbclient: client.o clitar.o getsmbpass.o $(UTILOBJ) 
  833. +smbclient: client.o clitar.o getsmbpass.o nmblib.o $(UTILOBJ) 
  834.      @echo Linking smbclient
  835. -    @$(CC) $(CFLAGS) -o smbclient client.o clitar.o getsmbpass.o $(UTILOBJ) $(LIBS)
  836. +    @$(CC) $(CFLAGS) -o smbclient client.o clitar.o getsmbpass.o nmblib.o $(UTILOBJ) $(LIBS)
  837.  
  838.  smbstatus: status.o $(PARAMOBJ) 
  839.      @echo Linking smbstatus
  840. @@ -517,17 +541,20 @@
  841.      @echo Linking smbpasswd
  842.      @$(CC) $(CFLAGS) -o smbpasswd smbpasswd.o getsmbpass.o $(PARAMOBJ) $(LIBS)
  843.  
  844. -install: installbin installman
  845. +install: installbin installman installscripts
  846.  
  847.  installbin: all
  848. -    @$(SHELL) $(srcdir)/installbin.sh $(INSTALLPERMS) $(BASEDIR) $(BINDIR) $(LIBDIR) $(VARDIR) $(PROGS) $(SCRIPTS)
  849. +    @$(SHELL) $(srcdir)installbin.sh $(INSTALLPERMS) $(BASEDIR) $(BINDIR) $(LIBDIR) $(VARDIR) $(PROGS)
  850. +
  851. +installscripts:
  852. +    @$(SHELL) $(srcdir)installbin.sh $(INSTALLPERMS) $(BASEDIR) $(BINDIR) $(LIBDIR) $(VARDIR) $(SCRIPTS)
  853.  
  854.  # revert to the previously installed version
  855.  revert:
  856. -    @$(SHELL) $(srcdir)/revert.sh $(BINDIR) $(PROGS) $(SCRIPTS)
  857. +    @$(SHELL) $(srcdir)revert.sh $(BINDIR) $(PROGS) $(SCRIPTS)
  858.  
  859.  installman:
  860. -    @$(SHELL) $(srcdir)/installman.sh $(MANDIR)
  861. +    @$(SHELL) $(srcdir)installman.sh $(MANDIR) $(srcdir)
  862.  
  863.  clean:
  864.      rm -f core *.o *~ $(PROGS)
  865. diff -u -r --new-file last-version/source/access.c samba-1.9.16alpha1/source/access.c
  866. --- last-version/source/access.c    Sat Sep  2 15:36:15 1995
  867. +++ samba-1.9.16alpha1/source/access.c    Sat Feb 24 19:04:53 1996
  868. @@ -317,7 +317,7 @@
  869.      if ((hp = gethostbyaddr((char *) &sockin->sin_addr,
  870.                  sizeof(sockin->sin_addr),
  871.                  AF_INET)) == 0) {
  872. -      DEBUG(0,("Gethostbyaddr failed\n"));
  873. +      DEBUG(1,("Gethostbyaddr failed for %s\n",addr_buf));
  874.  #ifdef ALLOW_PURE_ADDRESSES
  875.        takeAddressAsHostname = True;
  876.  #else
  877. diff -u -r --new-file last-version/source/change-log samba-1.9.16alpha1/source/change-log
  878. --- last-version/source/change-log    Tue Jan 16 20:30:53 1996
  879. +++ samba-1.9.16alpha1/source/change-log    Thu Feb 29 00:20:21 1996
  880. @@ -1752,14 +1752,55 @@
  881.      for SVR4
  882.      - GUEST_SESSSETUP change from David.Chappell@mail.cc.trincoll.edu
  883.      - released p7
  884. -    - moved SO_REUSEADDR before bind()
  885. +    - moved SO_REUSEADDR before bind() (thanks to Thomas Bellman 
  886. +    <tbe@ivab.se>)
  887.      - added more flexible GUEST_SESSSETUP to local.h and restored
  888.      pre-p7 behaviour as default
  889.      - released p8
  890. +    - Makefile fix from Marty Leisner <leisner@sdsp.mc.xerox.com>
  891. +    - added %g and %G substitutions
  892. +    - changed IDLE_CLOSED_TIMEOUT to 60 
  893. +    - fixed the "admin user" status in domain logons
  894. +    - hpux 10 "trusted security" patches from David-Michael Lincke
  895. +    (dlincke@sgcl1.unisg.ch)
  896. +    - added nmb lookups to client from Adrian Hill <Adrian.Hill@softimage.co.uk>
  897. +    - svr4 pause/resume printing patch from Brendan O'Dea (bod@tyndall.com.au)
  898. +    - fixed master announcement thanks to Luke Leighton <rah14@dial.pipex.com>
  899. +    - changed srcdir usage in Makefile to be friendly to more systems
  900. +    - NT4 alignment patches from Jeremy Allison (jra@vantive.com)
  901. +    - updated share mode code for new spec
  902. +    - minor client bugfix (for smbclient '\\\')
  903. +    - fix for level 260 when magling disabled. From Martin Tomes
  904. +    <Martin.Tomes@ecl.etherm.co.uk>
  905. +    - SMBtranss2 fix for OS/2 from Jeremy Allison
  906. +    - profiles fixup from Timm Wetzel <twetzel@cage.mpibpc.gwdg.de>
  907. +    - man page updates from Dirk.DeWachter@rug.ac.be
  908. +    - nmbsync fix from Andy Whitcroft <andy@soi.city.ac.uk>
  909. +    - Lynx patches from Manfred Woelfel <woelfel@hpesco1.fzk.de>
  910. +    - new smbtar stuff from Ricky
  911. +    - changed to share mode DENY_NONE for tar
  912. +    - fixed -D option of smbclient when in tar mode
  913. +    - added aARCH to open modes
  914. +    - added code to cope with select/read errors
  915. +    - fixed blank browse entries after smb.conf reread
  916. +    - integrated new browse stuff from Luke into ipc.c
  917. +    - added workgroup list to smbclient -L
  918. +    - improved archive attribute handling in close_file() and
  919. +    write_file()
  920. +    - smbtar fixes from Martin.Kraemer@mch.sni.de
  921. +    - Linux quota patch from xeno@mix.hsv.no
  922. +    - try to work around NT passlen2 problem in session setup
  923.      
  924.  ==========
  925.  todo:
  926.  
  927. +
  928. +64 bit longs and IP addresses may give problems with unsigned longs?
  929. +    
  930. +set archive bit whenever file is modified??
  931. +    
  932. +fix man page dates
  933. +
  934.  reply only to own workgroup in server enum
  935.      
  936.  patch to compile with g++ and possibly solaris c++
  937. @@ -1822,3 +1863,6 @@
  938.      
  939.  lpd stuff:
  940.       Tony Aiuto (tony@ics.com)
  941. +
  942. +make max disk size local
  943. +    
  944. \ No newline at end of file
  945. diff -u -r --new-file last-version/source/client.c samba-1.9.16alpha1/source/client.c
  946. --- last-version/source/client.c    Mon Jan 15 19:56:44 1996
  947. +++ samba-1.9.16alpha1/source/client.c    Thu Feb 29 00:12:08 1996
  948. @@ -24,6 +24,7 @@
  949.  #endif
  950.  
  951.  #include "includes.h"
  952. +#include "nameserv.h"
  953.  
  954.  #ifndef REGISTER
  955.  #define REGISTER 0
  956. @@ -40,6 +41,8 @@
  957.  BOOL got_pass = False;
  958.  BOOL connect_as_printer = False;
  959.  BOOL connect_as_ipc = False;
  960. +extern struct in_addr bcast_ip;
  961. +static BOOL got_bcast=False;
  962.  
  963.  char cryptkey[8];
  964.  BOOL doencrypt=False;
  965. @@ -76,6 +79,8 @@
  966.  extern int blocksize;
  967.  extern BOOL tar_inc;
  968.  extern BOOL tar_reset;
  969. +extern int process_tar();
  970. +extern int tar_parseargs();
  971.  /* clitar bits end */
  972.   
  973.  
  974. @@ -123,6 +128,8 @@
  975.  
  976.  extern int Client;
  977.  
  978. +#define USENMB
  979. +
  980.  #ifdef KANJI
  981.  extern int coding_system;
  982.  #define CNV_LANG(s) (coding_system == DOSV_CODE?s:dos_to_unix(s, False))
  983. @@ -421,40 +428,47 @@
  984.  
  985.  
  986.  /****************************************************************************
  987. +change directory - inner section
  988. +****************************************************************************/
  989. +static void do_cd(char *newdir)
  990. +{
  991. +  char *p = newdir;
  992. +  pstring saved_dir;
  993. +  pstring dname;
  994. +      
  995. +  /* Save the current directory in case the
  996. +     new directory is invalid */
  997. +  strcpy(saved_dir, cur_dir);
  998. +  if (*p == '\\')
  999. +    strcpy(cur_dir,p);
  1000. +  else
  1001. +    strcat(cur_dir,p);
  1002. +  if (*(cur_dir+strlen(cur_dir)-1) != '\\') {
  1003. +    strcat(cur_dir, "\\");
  1004. +  }
  1005. +  dos_clean_name(cur_dir);
  1006. +  strcpy(dname,cur_dir);
  1007. +  strcat(cur_dir,"\\");
  1008. +  dos_clean_name(cur_dir);
  1009. +
  1010. +  if (!strequal(cur_dir,"\\"))
  1011. +    if (!chkpath(dname,True))
  1012. +      strcpy(cur_dir,saved_dir);
  1013. +
  1014. +  strcpy(cd_path,cur_dir);
  1015. +}
  1016. +
  1017. +/****************************************************************************
  1018.  change directory
  1019.  ****************************************************************************/
  1020.  static void cmd_cd(char *inbuf,char *outbuf)
  1021.  {
  1022.    fstring buf;
  1023. -  char *p = buf;
  1024. -  pstring saved_dir;
  1025.  
  1026.    if (next_token(NULL,buf,NULL))
  1027. -    {
  1028. -      pstring dname;
  1029. -      
  1030. -      /* Save the current directory in case the
  1031. -     new directory is invalid */
  1032. -      strcpy(saved_dir, cur_dir);
  1033. -      if (*p == '\\')
  1034. -    strcpy(cur_dir,p);
  1035. -      else
  1036. -    strcat(cur_dir,p);
  1037. -      if (*(cur_dir+strlen(cur_dir)-1) != '\\') {
  1038. -    strcat(cur_dir, "\\");
  1039. -      }
  1040. -      dos_clean_name(cur_dir);
  1041. -      strcpy(dname,cur_dir);
  1042. -      strcat(cur_dir,"\\");
  1043. -      dos_clean_name(cur_dir);
  1044. -
  1045. -      if (!strequal(cur_dir,"\\"))
  1046. -    if (!chkpath(dname,True))
  1047. -      strcpy(cur_dir,saved_dir);
  1048. -    }
  1049. +    do_cd(buf);
  1050.    else
  1051.      DEBUG(0,("Current directory is %s\n",CNV_LANG(cur_dir)));
  1052. -  strcpy(cd_path,cur_dir);
  1053.  }
  1054.  
  1055.  
  1056. @@ -476,6 +490,7 @@
  1057.    ****************************************************************************/
  1058.  void do_dir(char *inbuf,char *outbuf,char *Mask,int attribute,void (*fn)(),BOOL recurse_dir)
  1059.  {
  1060. +  DEBUG(5,("do_dir(%s,%x,%s)\n",Mask,attribute,BOOLSTR(recurse_dir)));
  1061.    if (Protocol >= PROTOCOL_LANMAN2)
  1062.      {
  1063.        if (do_long_dir(inbuf,outbuf,Mask,attribute,fn,recurse_dir) > 0)
  1064. @@ -650,16 +665,13 @@
  1065.        if (!fn)
  1066.          DEBUG(0,("\n%s\n",CNV_LANG(cur_dir)));
  1067.  
  1068. +      strcat(mask2,"*");
  1069. +
  1070.        if (longdir)
  1071. -        {
  1072. -          strcat(mask2,"*");
  1073. -          do_long_dir(inbuf,outbuf,mask2,attribute,fn,True);      
  1074. -        }
  1075. +        do_long_dir(inbuf,outbuf,mask2,attribute,fn,True);      
  1076.        else
  1077. -        {
  1078. -          strcat(mask2,"*.*");
  1079. -          do_dir(inbuf,outbuf,mask2,attribute,fn,True);
  1080. -        }
  1081. +        do_dir(inbuf,outbuf,mask2,attribute,fn,True);
  1082. +
  1083.        strcpy(cur_dir,sav_dir);
  1084.      }
  1085.        else
  1086. @@ -1076,10 +1088,7 @@
  1087.      strcat(mask,p);
  1088.      }
  1089.    else {
  1090. -    if (Protocol < PROTOCOL_NT1)
  1091. -      strcat(mask,"*.*");
  1092. -    else
  1093. -      strcat(mask,"*");
  1094. +    strcat(mask,"*");
  1095.    }
  1096.  
  1097.    do_dir(inbuf,outbuf,mask,attribute,NULL,recurse);
  1098. @@ -1588,7 +1597,7 @@
  1099.        }       
  1100.  
  1101.        strcpy(mget_mask,cur_dir);
  1102. -      strcat(mget_mask,"*.*");
  1103. +      strcat(mget_mask,"*");
  1104.        
  1105.        do_dir((char *)inbuf,(char *)outbuf,
  1106.           mget_mask,aSYSTEM | aHIDDEN | aDIR,do_mget,False);
  1107. @@ -1668,7 +1677,7 @@
  1108.        strcpy(mget_mask,cur_dir);
  1109.        if(mget_mask[strlen(mget_mask)-1]!='\\')
  1110.      strcat(mget_mask,"\\");
  1111. -      strcat(mget_mask,"*.*");
  1112. +      strcat(mget_mask,"*");
  1113.        do_dir((char *)inbuf,(char *)outbuf,mget_mask,attribute,do_mget,False);
  1114.      }
  1115.  }
  1116. @@ -3116,7 +3125,7 @@
  1117.            
  1118.        DEBUG(0,("Session setup failed for username=%s myname=%s destname=%s   %s\n",
  1119.          username,myname,desthost,smb_errstr(inbuf)));
  1120. -      DEBUG(0,("You might find the -U or -n options useful\n"));
  1121. +      DEBUG(0,("You might find the -U, -W or -n options useful\n"));
  1122.        DEBUG(0,("Sometimes you have to use `-n USERNAME' (particularly with OS/2)\n"));
  1123.        DEBUG(0,("Some servers also insist on uppercase-only passwords\n"));
  1124.        if (was_null)
  1125. @@ -3564,8 +3573,6 @@
  1126.    int uLevel = 1;
  1127.    int count = 0;
  1128.  
  1129. -  int servertype = SV_TYPE_ALL; 
  1130. -
  1131.    /* now send a SMBtrans command with api ServerEnum? */
  1132.    p = param;
  1133.    SSVAL(p,0,0x68); /* api number */
  1134. @@ -3582,10 +3589,10 @@
  1135.    SSVAL(p,0,uLevel);
  1136.    SSVAL(p,2,0x2000); /* buf length */
  1137.    p += 4;
  1138. -  SIVAL(p,0,servertype);
  1139. -  p += 4;
  1140.  
  1141. -  if (call_api(PTR_DIFF(p,param),0,
  1142. +  SIVAL(p,0,SV_TYPE_ALL);
  1143. +
  1144. +  if (call_api(PTR_DIFF(p+4,param),0,
  1145.             8,10000,
  1146.             &rprcnt,&rdrcnt,
  1147.             param,NULL,
  1148. @@ -3595,29 +3602,63 @@
  1149.        int converter=SVAL(rparam,2);
  1150.        int i;
  1151.  
  1152. -      if (res == 0)
  1153. -    {
  1154. -      count=SVAL(rparam,4);
  1155. -      p = rdata;
  1156. +      if (res == 0) {    
  1157. +    char *p2 = rdata;
  1158. +    count=SVAL(rparam,4);
  1159.  
  1160. -      if (count > 0)
  1161. -    {
  1162. +    if (count > 0) {
  1163.        printf("\n\nThis machine has a browse list:\n");
  1164.        printf("\n\tServer               Comment\n");
  1165.        printf("\t---------            -------\n");
  1166.      }
  1167. -
  1168. -      for (i=0;i<count;i++)
  1169. -    {
  1170. -      char *sname = p;
  1171. -      int comment_offset = IVAL(p,22) & 0xFFFF;
  1172. +    
  1173. +    for (i=0;i<count;i++) {
  1174. +      char *sname = p2;
  1175. +      int comment_offset = IVAL(p2,22) & 0xFFFF;
  1176.        printf("\t%-16.16s     %s\n",
  1177.           sname,
  1178.           comment_offset?rdata+comment_offset-converter:"");
  1179.        
  1180. -      p += 26;
  1181. +      p2 += 26;
  1182.      }
  1183. +      }
  1184.      }
  1185. +
  1186. +  if (rparam) {free(rparam); rparam = NULL;}
  1187. +  if (rdata) {free(rdata); rdata = NULL;}
  1188. +
  1189. +  SIVAL(p,0,SV_TYPE_DOMAIN_ENUM);
  1190. +
  1191. +  if (call_api(PTR_DIFF(p+4,param),0,
  1192. +           8,10000,
  1193. +           &rprcnt,&rdrcnt,
  1194. +           param,NULL,
  1195. +           &rparam,&rdata))
  1196. +    {
  1197. +      int res = SVAL(rparam,0);
  1198. +      int converter=SVAL(rparam,2);
  1199. +      int i;
  1200. +
  1201. +      if (res == 0) {
  1202. +    char *p2 = rdata;
  1203. +    count=SVAL(rparam,4);
  1204. +
  1205. +    if (count > 0) {
  1206. +      printf("\n\nThis machine has a workgroup list:\n");
  1207. +      printf("\n\tWorkgroup            Master\n");
  1208. +      printf("\t---------            -------\n");
  1209. +    }
  1210. +    
  1211. +    for (i=0;i<count;i++) {
  1212. +      char *sname = p2;
  1213. +      int comment_offset = IVAL(p2,22) & 0xFFFF;
  1214. +      printf("\t%-16.16s     %s\n",
  1215. +         sname,
  1216. +         comment_offset?rdata+comment_offset-converter:"");
  1217. +      
  1218. +      p2 += 26;
  1219. +    }
  1220. +      }
  1221.      }
  1222.  
  1223.    if (rparam) free(rparam);
  1224. @@ -3671,10 +3712,10 @@
  1225.    {"exit",send_logout,"logoff the server"},
  1226.    {"newer",cmd_newer,"<file> only mget files newer than the specified local file"},
  1227.    {"archive",cmd_archive,"<level>\n0=ignore archive bit\n1=only get archive files\n2=only get archive files and reset archive bit\n3=get all files and reset archive bit"},
  1228. -  {"tar",cmd_tar,"tar current directory to <file name>" },
  1229. +  {"tar",cmd_tar,"tar <c|x>[IXbgNa] current directory to/from <file name>" },
  1230.    {"blocksize",cmd_block,"blocksize <number> (default 20)" },
  1231.    {"tarmode",cmd_tarmode,
  1232. -     "<mode=full|inc|reset|noreset> tar's behaviour towards archive bits" },
  1233. +     "<full|inc|reset|noreset> tar's behaviour towards archive bits" },
  1234.    {"setmode",cmd_setmode,"filename <setmode string> change modes of file"},
  1235.    {"help",cmd_help,"[command] give help on a command"},
  1236.    {"?",cmd_help,"[command] give help on a command"},
  1237. @@ -3690,7 +3731,7 @@
  1238.  static int process_tok(fstring tok)
  1239.  {
  1240.    int i = 0, matches = 0;
  1241. -  int cmd;
  1242. +  int cmd=0;
  1243.    int tok_len = strlen(tok);
  1244.    
  1245.    while (commands[i].fn != NULL)
  1246. @@ -3750,6 +3791,9 @@
  1247.    char *host;
  1248.    pstring service2;
  1249.    extern int Client;
  1250. +#ifdef USENMB
  1251. +  BOOL failed = True;
  1252. +#endif
  1253.  
  1254.    if (port == 0) port=last_port;
  1255.    last_port=port;
  1256. @@ -3764,6 +3808,10 @@
  1257.      {
  1258.        strcpy(service2,service);
  1259.        host = strtok(service2,"\\/");
  1260. +      if (!host) {
  1261. +    DEBUG(0,("Badly formed host name\n"));
  1262. +    return(False);
  1263. +      }
  1264.        strcpy(desthost,host);
  1265.      }
  1266.  
  1267. @@ -3779,13 +3827,34 @@
  1268.      {
  1269.        struct hostent *hp;
  1270.  
  1271. -      if ((hp = Get_Hostbyname(host)) == 0) 
  1272. -    {
  1273. +      if ((hp = Get_Hostbyname(host))) {
  1274. +    putip((char *)&dest_ip,(char *)hp->h_addr);
  1275. +    failed = False;
  1276. +      } else {
  1277. +#ifdef USENMB
  1278. +    /* Try and resolve the name with the netbios server */
  1279. +    int               bcast;
  1280. +    pstring        hs;
  1281. +    struct in_addr    ip1, ip2;
  1282. +    
  1283. +    if ((bcast = open_socket_in(SOCK_DGRAM, 0, 3)) != -1) {
  1284. +      set_socket_options (bcast, "SO_BROADCAST");
  1285. +
  1286. +      if (!got_bcast && get_myname(hs, &ip1)) {
  1287. +        get_broadcast(&ip1, &bcast_ip, &ip2);
  1288. +      }
  1289. +
  1290. +      if (name_query(bcast, host, 0x20, True, True, bcast_ip, &dest_ip,0)){
  1291. +        failed = False;
  1292. +      }
  1293. +      close (bcast);
  1294. +    }
  1295. +#endif
  1296. +    if (failed) {
  1297.        DEBUG(0,("Get_Hostbyname: Unknown host %s.\n",host));
  1298.        return False;
  1299.      }
  1300. -
  1301. -      putip((char *)&dest_ip,(char *)hp->h_addr);
  1302. +      }
  1303.      }
  1304.  
  1305.    Client = open_socket_out(SOCK_STREAM, &dest_ip, port);
  1306. @@ -3793,9 +3862,9 @@
  1307.      return False;
  1308.  
  1309.    DEBUG(3,("Connected\n"));
  1310. -
  1311. +  
  1312.    set_socket_options(Client,user_socket_options);  
  1313. -
  1314. +  
  1315.    return True;
  1316.  }
  1317.  
  1318. @@ -3906,7 +3975,7 @@
  1319.  /****************************************************************************
  1320.    process commands from the client
  1321.  ****************************************************************************/
  1322. -BOOL process(void )
  1323. +BOOL process(char *base_directory)
  1324.  {
  1325.    extern FILE *dbf;
  1326.    pstring line;
  1327. @@ -3922,6 +3991,8 @@
  1328.    if (!send_login(InBuffer,OutBuffer,True,True))
  1329.      return(False);
  1330.  
  1331. +  if (*base_directory) do_cd(base_directory);
  1332. +
  1333.    while (!feof(stdin))
  1334.      {
  1335.        fstring tok;
  1336. @@ -4008,6 +4079,8 @@
  1337.  #ifdef KANJI
  1338.    DEBUG(0,("\t-t terminal code      terminal i/o code {sjis|euc|jis7|jis8|junet|hex}\n"));
  1339.  #endif /* KANJI */
  1340. +  DEBUG(0,("\t-T<c|x>IXgbNa          command line tar\n"));
  1341. +  DEBUG(0,("\t-D directory          start from directory\n"));
  1342.    DEBUG(0,("\n"));
  1343.  }
  1344.  
  1345. @@ -4018,15 +4091,19 @@
  1346.  ****************************************************************************/
  1347.  int main(int argc,char *argv[])
  1348.  {
  1349. +  fstring base_directory;
  1350.    char *pname = argv[0];
  1351.    int port = 139;
  1352.    int opt;
  1353.    extern FILE *dbf;
  1354.    extern char *optarg;
  1355. +  extern int optind;
  1356.    pstring query_host;
  1357.    BOOL message = False;
  1358. +  extern char tar_type;
  1359.  
  1360.    *query_host = 0;
  1361. +  *base_directory = 0;
  1362.  
  1363.    DEBUGLEVEL = 2;
  1364.  
  1365. @@ -4095,9 +4172,9 @@
  1366.  
  1367.  #ifdef KANJI
  1368.    setup_term_code (KANJI);
  1369. -  while ((opt = getopt (argc, argv, "O:M:i:Nn:d:Pp:l:hI:EB:U:L:t:m:W:")) != EOF)
  1370. +  while ((opt = getopt (argc, argv, "B:O:M:i:Nn:d:Pp:l:hI:EB:U:L:t:m:W:T:D:")) != EOF)
  1371.  #else
  1372. -  while ((opt = getopt (argc, argv, "O:M:i:Nn:d:Pp:l:hI:EB:U:L:m:W:")) != EOF)
  1373. +  while ((opt = getopt (argc, argv, "B:O:M:i:Nn:d:Pp:l:hI:EB:U:L:m:W:T:D:")) != EOF)
  1374.  #endif /* KANJI */
  1375.      switch (opt)
  1376.        {
  1377. @@ -4113,6 +4190,19 @@
  1378.      strupper(desthost);
  1379.      message = True;
  1380.      break;
  1381. +      case 'B':
  1382. +    bcast_ip = *interpret_addr2(optarg);
  1383. +    got_bcast = True;
  1384. +    break;
  1385. +      case 'D':
  1386. +    strcpy(base_directory,optarg);
  1387. +    break;
  1388. +      case 'T':
  1389. +    if (!tar_parseargs(argc, argv, optarg, optind)) {
  1390. +      usage(pname);
  1391. +      exit(1);
  1392. +    }
  1393. +    break;
  1394.        case 'i':
  1395.      strcpy(scope,optarg);
  1396.      break;
  1397. @@ -4186,7 +4276,7 @@
  1398.      exit(1);
  1399.        }
  1400.  
  1401. -  if (!*query_host && !*service && !message)
  1402. +  if (!tar_type && !*query_host && !*service && !message)
  1403.      {
  1404.        usage(pname);
  1405.        exit(1);
  1406. @@ -4197,6 +4287,32 @@
  1407.  
  1408.    get_myname(*myname?NULL:myname,&myip);  
  1409.    strupper(myname);
  1410. +
  1411. +  if (tar_type) {
  1412. +    recurse=True;
  1413. +
  1414. +    if (open_sockets(port)) {
  1415. +        char *InBuffer = (char *)malloc(BUFFER_SIZE + SAFETY_MARGIN);
  1416. +    char *OutBuffer = (char *)malloc(BUFFER_SIZE + SAFETY_MARGIN);
  1417. +    int ret;
  1418. +
  1419. +    if ((InBuffer == NULL) || (OutBuffer == NULL)) 
  1420. +      return(1);
  1421. +
  1422. +    bzero(OutBuffer,smb_size);
  1423. +    if (!send_login(InBuffer,OutBuffer,True,True))
  1424. +      return(False);
  1425. +
  1426. +    if (*base_directory) do_cd(base_directory);
  1427. +
  1428. +    ret=process_tar(InBuffer, OutBuffer);
  1429. +
  1430. +    send_logout();
  1431. +    close_sockets();
  1432. +    return(ret);
  1433. +    } else
  1434. +      return(1);
  1435. +  }
  1436.    
  1437.    if (*query_host)
  1438.      {
  1439. @@ -4249,7 +4365,7 @@
  1440.  
  1441.    if (open_sockets(port))
  1442.      {
  1443. -      if (!process())
  1444. +      if (!process(base_directory))
  1445.      {
  1446.        close_sockets();
  1447.        return(1);
  1448. @@ -4301,6 +4417,7 @@
  1449.    {"ERRpipeclosing",232,"Pipe close in progress."},
  1450.    {"ERRnotconnected",233,"No process on other end of pipe."},
  1451.    {"ERRmoredata",234,"There is more data to be returned."},
  1452. +  {"ERRinvgroup",2455,"Invalid workgroup (try the -W option)"},
  1453.    {NULL,-1,NULL}};
  1454.  
  1455.  /* Server Error Messages */
  1456. diff -u -r --new-file last-version/source/clitar.c samba-1.9.16alpha1/source/clitar.c
  1457. --- last-version/source/clitar.c    Mon Jan 15 18:37:04 1996
  1458. +++ samba-1.9.16alpha1/source/clitar.c    Sat Feb 24 19:04:53 1996
  1459. @@ -27,6 +27,8 @@
  1460.  extern BOOL reopen_connection(char *inbuf,char *outbuf);
  1461.  extern void do_dir(char *inbuf,char *outbuf,char *Mask,int attribute,void (*fn)(),BOOL recurse_dir);
  1462.  
  1463. +int tar_parseargs(int argc, char *argv[], char *Optarg, int Optind);
  1464. +
  1465.  extern BOOL recurse;
  1466.  
  1467.  #define SEPARATORS " \t\n\r"
  1468. @@ -38,14 +40,23 @@
  1469.  #define ATTRSET 1
  1470.  #define ATTRRESET 0
  1471.  
  1472. +static int attribute = aDIR | aSYSTEM | aHIDDEN;
  1473. +
  1474.  #ifndef CLIENT_TIMEOUT
  1475.  #define CLIENT_TIMEOUT (30*1000)
  1476.  #endif
  1477.  
  1478.  static char *tarbuf;
  1479.  static int tp, ntarf, tbufsiz;
  1480. +/* Incremental mode */
  1481.  BOOL tar_inc=False;
  1482. +/* Reset archive bit */
  1483.  BOOL tar_reset=False;
  1484. +/* Include / exclude mode (true=include, false=exclude) */
  1485. +BOOL tar_excl=True;
  1486. +char tar_type='\0';
  1487. +static char **cliplist=NULL;
  1488. +static int clipn=0;
  1489.  
  1490.  extern file_info def_finfo;
  1491.  extern BOOL lowercase;
  1492. @@ -62,8 +73,7 @@
  1493.  
  1494.  static void writetarheader();
  1495.  static void do_atar();
  1496. -void do_tar();
  1497. -void cmd_tar();
  1498. +static void do_tar();
  1499.  static void oct_it();
  1500.  static void fixtarname();
  1501.  static int dotarbuf();
  1502. @@ -71,18 +81,23 @@
  1503.  static void dotareof();
  1504.  static void initarbuf();
  1505.  static int do_setrattr();
  1506. -
  1507. -/* begin smbrestore functions */
  1508. +void cmd_tar();
  1509. +int process_tar();
  1510. +char **toktocliplist();
  1511. +int clipfind();
  1512. +/* restore functions */
  1513.  static long readtarheader();
  1514.  static long unoct();
  1515.  static void do_tarput();
  1516.  static void unfixtarname();
  1517. -/* end smbrestore functions */
  1518.  
  1519.  /*
  1520. - * utitlity procedures to implement tar specification including buffering
  1521. + * tar specific utitlities
  1522.   */
  1523.  
  1524. +/****************************************************************************
  1525. +Write a tar header to buffer
  1526. +****************************************************************************/
  1527.  static void writetarheader(int f,  char *aname, int size, time_t mtime,
  1528.              char *amode)
  1529.  {
  1530. @@ -124,11 +139,90 @@
  1531.    (void) dotarbuf(f, hb.dummy, sizeof(hb.dummy));
  1532.  }
  1533.  
  1534. +/****************************************************************************
  1535. +Read a tar header into a hblock structure, and validate
  1536. +***************************************************************************/
  1537. +static long readtarheader(union hblock *hb, file_info *finfo, char *prefix)
  1538. +{
  1539. +  long chk, fchk;
  1540. +  int i;
  1541. +  char *jp;
  1542. +
  1543. +  /*
  1544. +   * read in a "standard" tar format header - we're not that interested
  1545. +   * in that many fields, though
  1546. +   */
  1547. +
  1548. +  /* check the checksum */
  1549. +  for (chk=0, i=sizeof(hb->dummy), jp=hb->dummy; --i>=0;) chk+=(0xFF & *jp++);
  1550. +
  1551. +  if (chk == 0)
  1552. +    return chk;
  1553. +
  1554. +  /* compensate for blanks in chksum header */
  1555. +  for (i=sizeof(hb->dbuf.chksum), jp=hb->dbuf.chksum; --i>=0;)
  1556. +    chk-=(0xFF & *jp++);
  1557. +
  1558. +  chk += ' ' * sizeof(hb->dbuf.chksum);
  1559. +
  1560. +  fchk=unoct(hb->dbuf.chksum, sizeof(hb->dbuf.chksum));
  1561. +
  1562. +  DEBUG(5, ("checksum totals chk=%d fchk=%d chksum=%s\n",
  1563. +        chk, fchk, hb->dbuf.chksum));
  1564. +
  1565. +  if (fchk != chk)
  1566. +    {
  1567. +      DEBUG(0, ("checksums don't match %d %d\n", fchk, chk));
  1568. +      return -1;
  1569. +    }
  1570. +
  1571. +  strcpy(finfo->name, prefix);
  1572. +
  1573. +  /* use l + 1 to do the null too; do prefix - prefcnt to zap leading slash */
  1574. +  unfixtarname(finfo->name + strlen(prefix), hb->dbuf.name,
  1575. +           strlen(hb->dbuf.name) + 1);
  1576. +
  1577. +/* can't handle links at present */
  1578. +  if (hb->dbuf.linkflag != '0') {
  1579. +    if (hb->dbuf.linkflag == 0) {
  1580. +      DEBUG(6, ("Warning: NULL link flag (gnu tar archive ?) %s\n",
  1581. +        finfo->name));
  1582. +    } else { 
  1583. +      DEBUG(0, ("this tar file appears to contain some kind of link - ignoring\n"));
  1584. +      return -2;
  1585. +    }
  1586. +  }
  1587. +    
  1588. +  if ((unoct(hb->dbuf.mode, sizeof(hb->dbuf.mode)) & S_IFDIR)
  1589. +    || (*(finfo->name+strlen(finfo->name)-1) == '\\'))
  1590. +    {
  1591. +      finfo->mode=aDIR;
  1592. +    }
  1593. +  else
  1594. +    finfo->mode=0; /* we don't care about mode at the moment, we'll
  1595. +            * just make it a regular file */
  1596. +  /*
  1597. +   * Bug fix by richard@sj.co.uk
  1598. +   *
  1599. +   * REC: restore times correctly (as does tar)
  1600. +   * We only get the modification time of the file; set the creation time
  1601. +   * from the mod. time, and the access time to current time
  1602. +   */
  1603. +  finfo->mtime = finfo->ctime = strtol(hb->dbuf.mtime, NULL, 8);
  1604. +  finfo->atime = time(NULL);
  1605. +  finfo->size = unoct(hb->dbuf.size, sizeof(hb->dbuf.size));
  1606. +
  1607. +  return True;
  1608. +}
  1609.  
  1610. +/****************************************************************************
  1611. +Write out the tar buffer to tape or wherever
  1612. +****************************************************************************/
  1613.  static int dotarbuf(int f, char *b, int n)
  1614.  {
  1615.    int fail=1, writ=n;
  1616.  
  1617. +  /* This routine and the next one should be the only ones that do write()s */
  1618.    if (tp + n >= tbufsiz)
  1619.      {
  1620.        int diff;
  1621. @@ -155,6 +249,9 @@
  1622.    return(fail ? writ : 0);
  1623.  }
  1624.  
  1625. +/****************************************************************************
  1626. +Write a zeros to buffer / tape
  1627. +****************************************************************************/
  1628.  static void dozerobuf(int f, int n)
  1629.  {
  1630.    /* short routine just to write out n zeros to buffer -
  1631. @@ -174,6 +271,9 @@
  1632.      }
  1633.  }
  1634.  
  1635. +/****************************************************************************
  1636. +Malloc tape buffer
  1637. +****************************************************************************/
  1638.  static void initarbuf()
  1639.  {
  1640.    /* initialize tar buffer */
  1641. @@ -184,11 +284,13 @@
  1642.    tp=0; ntarf=0;
  1643.  }
  1644.  
  1645. +/****************************************************************************
  1646. +Write two zero blocks at end of file
  1647. +****************************************************************************/
  1648.  static void dotareof(int f)
  1649.  {
  1650.    struct stat stbuf;
  1651. -  /* Two zero blocks at end of file, write out full buffer
  1652. -   * no matter what; well that's what the manual says */
  1653. +  /* Two zero blocks at end of file, write out full buffer */
  1654.  
  1655.    (void) dozerobuf(f, TBLOCK);
  1656.    (void) dozerobuf(f, TBLOCK);
  1657. @@ -199,9 +301,14 @@
  1658.        return;
  1659.      }
  1660.  
  1661. +  /* Could be a pipe, in which case S_ISREG should fail,
  1662. +   * and we should write out at full size */
  1663.    if (tp > 0) write(f, tarbuf, S_ISREG(stbuf.st_mode) ? tp : tbufsiz);
  1664.  }
  1665.  
  1666. +/****************************************************************************
  1667. +(Un)mangle DOS pathname, make nonabsolute
  1668. +****************************************************************************/
  1669.  static void fixtarname(char *tptr, char *fp, int l)
  1670.  {
  1671.    /* add a '.' to start of file name, convert from ugly dos \'s in path
  1672. @@ -231,6 +338,9 @@
  1673.  #endif
  1674.  }
  1675.  
  1676. +/****************************************************************************
  1677. +Convert from decimal to octal string
  1678. +****************************************************************************/
  1679.  static void oct_it (register long value, register int ndgs, register char *p)
  1680.  {
  1681.    /* Converts long to octal string, pads with leading zeros */
  1682. @@ -251,10 +361,47 @@
  1683.      p[--ndgs] = '0';
  1684.  }
  1685.  
  1686. +/****************************************************************************
  1687. +Convert from octal string to long
  1688. +***************************************************************************/
  1689. +static long unoct(char *p, int ndgs)
  1690. +{
  1691. +  long value=0;
  1692. +  /* Converts octal string to long, ignoring any non-digit */
  1693. +
  1694. +  while (--ndgs)
  1695. +    {
  1696. +      if (isdigit(*p))
  1697. +        value = (value << 3) | (long) (*p - '0');
  1698. +
  1699. +      p++;
  1700. +    }
  1701. +
  1702. +  return value;
  1703. +}
  1704. +
  1705. +/****************************************************************************
  1706. +Compare two strings in a slash insensitive way
  1707. +***************************************************************************/
  1708. +int strslashcmp(const char *s1, const char *s2)
  1709. +{
  1710. +  while(*s1 && *s2 &&
  1711. +    (*s1 == *s2
  1712. +     || tolower(*s1) == tolower(*s2)
  1713. +     || (*s1 == '\\' && *s2=='/')
  1714. +     || (*s1 == '/' && *s2=='\\'))) {
  1715. +      s1++; s2++;
  1716. +  }
  1717. +
  1718. +  return *s1-*s2;
  1719. +}
  1720. +
  1721.  /*
  1722.   * general smb utility functions
  1723.   */
  1724. -
  1725. +/****************************************************************************
  1726. +Set DOS file attributes
  1727. +***************************************************************************/
  1728.  static int do_setrattr(char *fname, int attr, int setit)
  1729.  {
  1730.    /*
  1731. @@ -347,122 +494,338 @@
  1732.    return(True);
  1733.  }
  1734.  
  1735. -/*
  1736. - * smbclient support procedures
  1737. - */
  1738. -
  1739.  /****************************************************************************
  1740. - do a tar operation on one file
  1741. +Create a file on a share
  1742.  ***************************************************************************/
  1743. -
  1744. -static void do_atar(char *rname,char *lname,file_info *finfo1)
  1745. +static BOOL smbcreat(file_info finfo, int *fnum, char *inbuf, char *outbuf)
  1746.  {
  1747. -  int fnum;
  1748. -  uint32 nread=0;
  1749.    char *p;
  1750. -  char *inbuf,*outbuf;
  1751. -  file_info finfo;
  1752. -  BOOL close_done = False;
  1753. -  BOOL shallitime=True;
  1754. -  BOOL ignore_close_error = False;
  1755. -  char *dataptr=NULL;
  1756. -  int datalen=0;
  1757. -
  1758. -  struct timeval tp_start;
  1759. -  GetTimeOfDay(&tp_start);
  1760. -
  1761. -  if (finfo1) 
  1762. -    finfo = *finfo1;
  1763. -  else
  1764. -    finfo = def_finfo;
  1765. -
  1766. -  inbuf = (char *)malloc(BUFFER_SIZE + SAFETY_MARGIN);
  1767. -  outbuf = (char *)malloc(BUFFER_SIZE + SAFETY_MARGIN);
  1768. -
  1769. -  if (!inbuf || !outbuf)
  1770. -    {
  1771. -      DEBUG(0,("out of memory\n"));
  1772. -      return;
  1773. -    }
  1774. -
  1775. +  /* *must* be called with buffer ready malloc'ed */
  1776. +  /* open remote file */
  1777. +  
  1778.    memset(outbuf,0,smb_size);
  1779. -  set_message(outbuf,15,1 + strlen(rname),True);
  1780. -
  1781. -  CVAL(outbuf,smb_com) = SMBopenX;
  1782. +  set_message(outbuf,3,2 + strlen(finfo.name),True);
  1783. +  CVAL(outbuf,smb_com) = SMBcreate;
  1784.    SSVAL(outbuf,smb_tid,cnum);
  1785.    setup_pkt(outbuf);
  1786. -
  1787. -  SSVAL(outbuf,smb_vwv0,0xFF);
  1788. -  SSVAL(outbuf,smb_vwv2,1);
  1789. -  SSVAL(outbuf,smb_vwv4,aSYSTEM | aHIDDEN);
  1790. -  SSVAL(outbuf,smb_vwv5,aSYSTEM | aHIDDEN);
  1791. -  SSVAL(outbuf,smb_vwv8,1);
  1792. -
  1793. +  
  1794. +  SSVAL(outbuf,smb_vwv0,finfo.mode);
  1795. +  put_dos_date3(outbuf,smb_vwv1,finfo.mtime);
  1796. +  
  1797.    p = smb_buf(outbuf);
  1798. -  strcpy(p,rname);
  1799. -  p = skip_string(p,1);
  1800. -
  1801. -  dos_clean_name(rname);
  1802. -
  1803. -  /* do a chained openX with a readX? */  
  1804. -  if (finfo.size > 0)
  1805. -    {
  1806. -      SSVAL(outbuf,smb_vwv0,SMBreadX);
  1807. -      SSVAL(outbuf,smb_vwv1,PTR_DIFF(p,outbuf) - 4);
  1808. -      memset(p,0,200);
  1809. -      p -= smb_wct;
  1810. -      SSVAL(p,smb_wct,10);
  1811. -      SSVAL(p,smb_vwv0,0xFF);
  1812. -      SSVAL(p,smb_vwv5,MIN(max_xmit-500,finfo.size));
  1813. -      SSVAL(p,smb_vwv9,MIN(0xFFFF,finfo.size));
  1814. -      smb_setlen(outbuf,smb_len(outbuf)+11*2+1);  
  1815. -    }
  1816. +  *p++ = 4;      
  1817. +  strcpy(p,finfo.name);
  1818.    
  1819.    send_smb(Client,outbuf);
  1820.    receive_smb(Client,inbuf,CLIENT_TIMEOUT);
  1821. -
  1822. +  
  1823.    if (CVAL(inbuf,smb_rcls) != 0)
  1824.      {
  1825. -      if (CVAL(inbuf,smb_rcls) == ERRSRV &&
  1826. -      SVAL(inbuf,smb_err) == ERRnoresource &&
  1827. -      reopen_connection(inbuf,outbuf))
  1828. -    {
  1829. -      do_atar(rname,lname,finfo1);
  1830. -      free(inbuf);free(outbuf);
  1831. -      return;
  1832. -    }
  1833. -
  1834. -      DEBUG(0,("%s opening remote file %s\n",smb_errstr(inbuf),rname));
  1835. -      free(inbuf);free(outbuf);
  1836. -      return;
  1837. -    }
  1838. -
  1839. -  strcpy(finfo.name,rname);
  1840. -  if (!finfo1)
  1841. -    {
  1842. -      finfo.mode = SVAL(inbuf,smb_vwv3);
  1843. -      finfo.size = IVAL(inbuf,smb_vwv4);
  1844. -      finfo.mtime = make_unix_date3(inbuf+smb_vwv6);
  1845. -      finfo.atime = finfo.ctime = finfo.mtime;
  1846. +      DEBUG(0,("%s opening remote file %s\n",smb_errstr(inbuf),
  1847. +           finfo.name));
  1848. +      return 0;
  1849.      }
  1850. +  
  1851. +  *fnum = SVAL(inbuf,smb_vwv0);
  1852. +  return True;
  1853. +}
  1854.  
  1855. -  DEBUG(3,("file %s attrib 0x%X\n",finfo.name,finfo.mode));
  1856. +/****************************************************************************
  1857. +Write a file to a share
  1858. +***************************************************************************/
  1859. +static BOOL smbwrite(int fnum, int n, int low, int high, int left,
  1860. +             char *bufferp, char *inbuf, char *outbuf)
  1861. +{
  1862. +  /* *must* be called with buffer ready malloc'ed */
  1863.  
  1864. -  fnum = SVAL(inbuf,smb_vwv2);
  1865. +  memset(outbuf,0,smb_size);
  1866. +  set_message(outbuf,5,n + 3,True);
  1867. +  
  1868. +  memcpy(smb_buf(outbuf)+3, bufferp, n);
  1869. +  
  1870. +  set_message(outbuf,5,n + 3, False);
  1871. +  CVAL(outbuf,smb_com) = SMBwrite;
  1872. +  SSVAL(outbuf,smb_tid,cnum);
  1873. +  setup_pkt(outbuf);
  1874. +  
  1875. +  SSVAL(outbuf,smb_vwv0,fnum);
  1876. +  SSVAL(outbuf,smb_vwv1,n);
  1877. +  SIVAL(outbuf,smb_vwv2,low);
  1878. +  SSVAL(outbuf,smb_vwv4,left);
  1879. +  CVAL(smb_buf(outbuf),0) = 1;
  1880. +  SSVAL(smb_buf(outbuf),1,n);
  1881.  
  1882. -  if (tar_inc && !(finfo.mode & aARCH))
  1883. +  send_smb(Client,outbuf); 
  1884. +  receive_smb(Client,inbuf,CLIENT_TIMEOUT);
  1885. +  
  1886. +  if (CVAL(inbuf,smb_rcls) != 0)
  1887.      {
  1888. -      DEBUG(4, ("skipping %s - archive bit not set\n", finfo.name));
  1889. -      shallitime=0;
  1890. +      DEBUG(0,("%s writing remote file\n",smb_errstr(inbuf)));
  1891. +      return False;
  1892.      }
  1893. -  else
  1894. +  
  1895. +  if (n != SVAL(inbuf,smb_vwv0))
  1896.      {
  1897. -      if (SVAL(inbuf,smb_vwv0) == SMBreadX)
  1898. -    {
  1899. -      p = (inbuf+4+SVAL(inbuf,smb_vwv1)) - smb_wct;
  1900. -      datalen = SVAL(p,smb_vwv5);
  1901. -      dataptr = inbuf + 4 + SVAL(p,smb_vwv6);
  1902. -    }
  1903. +      DEBUG(0,("Error: only wrote %d bytes out of %d\n",
  1904. +           SVAL(inbuf,smb_vwv0), n));
  1905. +      return False;
  1906. +    }
  1907. +
  1908. +  return True;
  1909. +}
  1910. +
  1911. +/****************************************************************************
  1912. +Close a file on a share
  1913. +***************************************************************************/
  1914. +static BOOL smbshut(file_info finfo, int fnum, char *inbuf, char *outbuf)
  1915. +{
  1916. +  /* *must* be called with buffer ready malloc'ed */
  1917. +
  1918. +  memset(outbuf,0,smb_size);
  1919. +  set_message(outbuf,3,0,True);
  1920. +  CVAL(outbuf,smb_com) = SMBclose;
  1921. +  SSVAL(outbuf,smb_tid,cnum);
  1922. +  setup_pkt(outbuf);
  1923. +  
  1924. +  SSVAL(outbuf,smb_vwv0,fnum);
  1925. +  put_dos_date3(outbuf,smb_vwv1,finfo.mtime);
  1926. +  
  1927. +  DEBUG(3,("Setting date to %s (0x%X)",
  1928. +       asctime(LocalTime(&finfo.mtime,GMT_TO_LOCAL)),
  1929. +       finfo.mtime));
  1930. +  
  1931. +  send_smb(Client,outbuf);
  1932. +  receive_smb(Client,inbuf,CLIENT_TIMEOUT);
  1933. +  
  1934. +  if (CVAL(inbuf,smb_rcls) != 0)
  1935. +    {
  1936. +      DEBUG(0,("%s closing remote file %s\n",smb_errstr(inbuf),
  1937. +           finfo.name));
  1938. +      return False;
  1939. +    }
  1940. +
  1941. +  return True;
  1942. +}
  1943. +
  1944. +/****************************************************************************
  1945. +Verify existence of path on share
  1946. +***************************************************************************/
  1947. +static BOOL smbchkpath(char *fname, char *inbuf, char *outbuf)
  1948. +{
  1949. +  char *p;
  1950. +
  1951. +  memset(outbuf,0,smb_size);
  1952. +  set_message(outbuf,0,4 + strlen(fname),True);
  1953. +  CVAL(outbuf,smb_com) = SMBchkpth;
  1954. +  SSVAL(outbuf,smb_tid,cnum);
  1955. +  setup_pkt(outbuf);
  1956. +
  1957. +  p = smb_buf(outbuf);
  1958. +  *p++ = 4;
  1959. +  strcpy(p,fname);
  1960. +
  1961. +  send_smb(Client,outbuf);
  1962. +  receive_smb(Client,inbuf,CLIENT_TIMEOUT);
  1963. +
  1964. +  DEBUG(5,("smbchkpath: %s\n",smb_errstr(inbuf)));
  1965. +
  1966. +  return(CVAL(inbuf,smb_rcls) == 0);
  1967. +}
  1968. +
  1969. +/****************************************************************************
  1970. +Make a directory on share
  1971. +***************************************************************************/
  1972. +static BOOL smbmkdir(char *fname, char *inbuf, char *outbuf)
  1973. +{
  1974. +  /* *must* be called with buffer ready malloc'ed */
  1975. +  char *p;
  1976. +
  1977. +  memset(outbuf,0,smb_size);
  1978. +  set_message(outbuf,0,2 + strlen(fname),True);
  1979. +  
  1980. +  CVAL(outbuf,smb_com) = SMBmkdir;
  1981. +  SSVAL(outbuf,smb_tid,cnum);
  1982. +  setup_pkt(outbuf);
  1983. +  
  1984. +  p = smb_buf(outbuf);
  1985. +  *p++ = 4;      
  1986. +  strcpy(p,fname);
  1987. +  
  1988. +  send_smb(Client,outbuf);
  1989. +  receive_smb(Client,inbuf,CLIENT_TIMEOUT);
  1990. +  
  1991. +  if (CVAL(inbuf,smb_rcls) != 0)
  1992. +    {
  1993. +      DEBUG(0,("%s making remote directory %s\n",
  1994. +           smb_errstr(inbuf),fname));
  1995. +      return(False);
  1996. +    }
  1997. +
  1998. +  return(True);
  1999. +}
  2000. +
  2001. +/****************************************************************************
  2002. +Ensure a remote path exists (make if necessary)
  2003. +***************************************************************************/
  2004. +static BOOL ensurepath(char *fname, char *inbuf, char *outbuf)
  2005. +{
  2006. +  /* *must* be called with buffer ready malloc'ed */
  2007. +  /* ensures path exists */
  2008. +
  2009. +  pstring partpath, ffname;
  2010. +  char *p=fname, *basehack;
  2011. +
  2012. +  *partpath = 0;
  2013. +
  2014. +  /* fname copied to ffname so can strtok */
  2015. +
  2016. +  strcpy(ffname, fname);
  2017. +
  2018. +  /* do a `basename' on ffname, so don't try and make file name directory */
  2019. +  if ((basehack=strrchr(ffname, '\\')) == NULL)
  2020. +    return True;
  2021. +  else
  2022. +    *basehack='\0';
  2023. +
  2024. +  p=strtok(ffname, "\\");
  2025. +
  2026. +  while (p)
  2027. +    {
  2028. +      strcat(partpath, p);
  2029. +
  2030. +      if (!smbchkpath(partpath, inbuf, outbuf)) {
  2031. +    if (!smbmkdir(partpath, inbuf, outbuf))
  2032. +      {
  2033. +        DEBUG(0, ("Error mkdirhiering\n"));
  2034. +        return False;
  2035. +      }
  2036. +    else
  2037. +      DEBUG(3, ("mkdirhiering %s\n", partpath));
  2038. +
  2039. +      }
  2040. +
  2041. +      strcat(partpath, "\\");
  2042. +      p = strtok(NULL,"/\\");
  2043. +    }
  2044. +
  2045. +    return True;
  2046. +}
  2047. +
  2048. +/*
  2049. + * smbclient functions
  2050. + */
  2051. +/****************************************************************************
  2052. +append one remote file to the tar file
  2053. +***************************************************************************/
  2054. +static void do_atar(char *rname,char *lname,file_info *finfo1)
  2055. +{
  2056. +  int fnum;
  2057. +  uint32 nread=0;
  2058. +  char *p;
  2059. +  char *inbuf,*outbuf;
  2060. +  file_info finfo;
  2061. +  BOOL close_done = False;
  2062. +  BOOL shallitime=True;
  2063. +  BOOL ignore_close_error = False;
  2064. +  char *dataptr=NULL;
  2065. +  int datalen=0;
  2066. +
  2067. +  struct timeval tp_start;
  2068. +  GetTimeOfDay(&tp_start);
  2069. +
  2070. +  if (finfo1) 
  2071. +    finfo = *finfo1;
  2072. +  else
  2073. +    finfo = def_finfo;
  2074. +
  2075. +  inbuf = (char *)malloc(BUFFER_SIZE + SAFETY_MARGIN);
  2076. +  outbuf = (char *)malloc(BUFFER_SIZE + SAFETY_MARGIN);
  2077. +
  2078. +  if (!inbuf || !outbuf)
  2079. +    {
  2080. +      DEBUG(0,("out of memory\n"));
  2081. +      return;
  2082. +    }
  2083. +
  2084. +  memset(outbuf,0,smb_size);
  2085. +  set_message(outbuf,15,1 + strlen(rname),True);
  2086. +
  2087. +  CVAL(outbuf,smb_com) = SMBopenX;
  2088. +  SSVAL(outbuf,smb_tid,cnum);
  2089. +  setup_pkt(outbuf);
  2090. +
  2091. +  SSVAL(outbuf,smb_vwv0,0xFF);
  2092. +  SSVAL(outbuf,smb_vwv2,1);
  2093. +  SSVAL(outbuf,smb_vwv3,(DENY_NONE<<4));
  2094. +  SSVAL(outbuf,smb_vwv4,aSYSTEM | aHIDDEN);
  2095. +  SSVAL(outbuf,smb_vwv5,aSYSTEM | aHIDDEN);
  2096. +  SSVAL(outbuf,smb_vwv8,1);
  2097. +
  2098. +  p = smb_buf(outbuf);
  2099. +  strcpy(p,rname);
  2100. +  p = skip_string(p,1);
  2101. +
  2102. +  dos_clean_name(rname);
  2103. +
  2104. +  /* do a chained openX with a readX? */  
  2105. +  if (finfo.size > 0)
  2106. +    {
  2107. +      SSVAL(outbuf,smb_vwv0,SMBreadX);
  2108. +      SSVAL(outbuf,smb_vwv1,PTR_DIFF(p,outbuf) - 4);
  2109. +      memset(p,0,200);
  2110. +      p -= smb_wct;
  2111. +      SSVAL(p,smb_wct,10);
  2112. +      SSVAL(p,smb_vwv0,0xFF);
  2113. +      SSVAL(p,smb_vwv5,MIN(max_xmit-500,finfo.size));
  2114. +      SSVAL(p,smb_vwv9,MIN(0xFFFF,finfo.size));
  2115. +      smb_setlen(outbuf,smb_len(outbuf)+11*2+1);  
  2116. +    }
  2117. +  
  2118. +  send_smb(Client,outbuf);
  2119. +  receive_smb(Client,inbuf,CLIENT_TIMEOUT);
  2120. +
  2121. +  if (CVAL(inbuf,smb_rcls) != 0)
  2122. +    {
  2123. +      if (CVAL(inbuf,smb_rcls) == ERRSRV &&
  2124. +      SVAL(inbuf,smb_err) == ERRnoresource &&
  2125. +      reopen_connection(inbuf,outbuf))
  2126. +    {
  2127. +      do_atar(rname,lname,finfo1);
  2128. +      free(inbuf);free(outbuf);
  2129. +      return;
  2130. +    }
  2131. +
  2132. +      DEBUG(0,("%s opening remote file %s\n",smb_errstr(inbuf),rname));
  2133. +      free(inbuf);free(outbuf);
  2134. +      return;
  2135. +    }
  2136. +
  2137. +  strcpy(finfo.name,rname);
  2138. +  if (!finfo1)
  2139. +    {
  2140. +      finfo.mode = SVAL(inbuf,smb_vwv3);
  2141. +      finfo.size = IVAL(inbuf,smb_vwv4);
  2142. +      finfo.mtime = make_unix_date3(inbuf+smb_vwv6);
  2143. +      finfo.atime = finfo.ctime = finfo.mtime;
  2144. +    }
  2145. +
  2146. +  DEBUG(3,("file %s attrib 0x%X\n",finfo.name,finfo.mode));
  2147. +
  2148. +  fnum = SVAL(inbuf,smb_vwv2);
  2149. +
  2150. +  if (tar_inc && !(finfo.mode & aARCH))
  2151. +    {
  2152. +      DEBUG(4, ("skipping %s - archive bit not set\n", finfo.name));
  2153. +      shallitime=0;
  2154. +    }
  2155. +  else
  2156. +    {
  2157. +      if (SVAL(inbuf,smb_vwv0) == SMBreadX)
  2158. +    {
  2159. +      p = (inbuf+4+SVAL(inbuf,smb_vwv1)) - smb_wct;
  2160. +      datalen = SVAL(p,smb_vwv5);
  2161. +      dataptr = inbuf + 4 + SVAL(p,smb_vwv6);
  2162. +    }
  2163.        else
  2164.      {
  2165.        dataptr = NULL;
  2166. @@ -722,390 +1085,119 @@
  2167.      (tp_end.tv_sec - tp_start.tv_sec)*1000 +
  2168.        (tp_end.tv_usec - tp_start.tv_usec)/1000;
  2169.        get_total_time_ms += this_time;
  2170. -      get_total_size += finfo.size;
  2171. -      
  2172. -      DEBUG(2,("(%g kb/s) (average %g kb/s)\n",
  2173. -           finfo.size / (1.024*this_time + 1.0e-4),
  2174. -           get_total_size / (1.024*get_total_time_ms)));
  2175. -    }
  2176. -  
  2177. -  free(inbuf);free(outbuf);
  2178. -}
  2179. -
  2180. -
  2181. -
  2182. -void do_tar(file_info *finfo)
  2183. -{
  2184. -  pstring rname;
  2185. -
  2186. -  if (strequal(finfo->name,".") || strequal(finfo->name,".."))
  2187. -    return;
  2188. -
  2189. -  if (finfo->mode & aDIR)
  2190. -    {
  2191. -      pstring saved_curdir;
  2192. -      pstring mtar_mask;
  2193. -      char *inbuf,*outbuf;
  2194. -
  2195. -      inbuf = (char *)malloc(BUFFER_SIZE + SAFETY_MARGIN);
  2196. -      outbuf = (char *)malloc(BUFFER_SIZE + SAFETY_MARGIN);
  2197. -
  2198. -      if (!inbuf || !outbuf)
  2199. -    {
  2200. -      DEBUG(0,("out of memory\n"));
  2201. -      return;
  2202. -    }
  2203. -
  2204. -      strcpy(saved_curdir,cur_dir);
  2205. -
  2206. -      strcat(cur_dir,finfo->name);
  2207. -      strcat(cur_dir,"\\");
  2208. -
  2209. -      /* write a tar directory, don't bother with mode - just set it to
  2210. -       * 40755 */
  2211. -      writetarheader(tarhandle, cur_dir, 0, finfo->mtime, "040755 \0");
  2212. -      strcpy(mtar_mask,cur_dir);
  2213. -      strcat(mtar_mask,"*.*");
  2214. -      
  2215. -      do_dir((char *)inbuf,(char *)outbuf,
  2216. -         mtar_mask,aSYSTEM | aHIDDEN | aDIR,do_tar,recurse);
  2217. -      strcpy(cur_dir,saved_curdir);
  2218. -      free(inbuf);free(outbuf);
  2219. -    }
  2220. -  else
  2221. -    {
  2222. -      strcpy(rname,cur_dir);
  2223. -      strcat(rname,finfo->name);
  2224. -      do_atar(rname,finfo->name,finfo);
  2225. -    }
  2226. -}
  2227. -
  2228. -/*
  2229. - *
  2230. - * restore specific functions
  2231. - *
  2232. - */
  2233. -
  2234. -static long readtarheader(union hblock *hb, file_info *finfo, char *prefix)
  2235. -{
  2236. -  long chk, fchk;
  2237. -  int i;
  2238. -  char *jp;
  2239. -
  2240. -  /*
  2241. -   * read in a "standard" tar format header - we're not that interested
  2242. -   * in that many fields, though
  2243. -   */
  2244. -
  2245. -  /* check the checksum */
  2246. -  for (chk=0, i=sizeof(hb->dummy), jp=hb->dummy; --i>=0;) chk+=(0xFF & *jp++);
  2247. -
  2248. -  if (chk == 0)
  2249. -    return chk;
  2250. -
  2251. -  /* compensate for blanks in chksum header */
  2252. -  for (i=sizeof(hb->dbuf.chksum), jp=hb->dbuf.chksum; --i>=0;)
  2253. -    chk-=(0xFF & *jp++);
  2254. -
  2255. -  chk += ' ' * sizeof(hb->dbuf.chksum);
  2256. -
  2257. -  fchk=unoct(hb->dbuf.chksum, sizeof(hb->dbuf.chksum));
  2258. -
  2259. -  DEBUG(5, ("checksum totals chk=%d fchk=%d chksum=%s\n",
  2260. -        chk, fchk, hb->dbuf.chksum));
  2261. -
  2262. -  if (fchk != chk)
  2263. -    {
  2264. -      DEBUG(0, ("checksums don't match %d %d\n", fchk, chk));
  2265. -      return -1;
  2266. -    }
  2267. -
  2268. -  strcpy(finfo->name, prefix);
  2269. -
  2270. -  /* use l + 1 to do the null too; do prefix - prefcnt to zap leading slash */
  2271. -  unfixtarname(finfo->name + strlen(prefix), hb->dbuf.name,
  2272. -           strlen(hb->dbuf.name) + 1);
  2273. -
  2274. -/* can't handle links at present */
  2275. -  if (hb->dbuf.linkflag != '0') {
  2276. -    if (hb->dbuf.linkflag == 0) {
  2277. -      DEBUG(4, ("Warning: NULL link detected %s\n", finfo->name));
  2278. -    } else { 
  2279. -      DEBUG(0, ("this tar file appears to contain some kind of link - ignoring\n"));
  2280. -      return -2;
  2281. -    }
  2282. -  }
  2283. -    
  2284. -  if ((unoct(hb->dbuf.mode, sizeof(hb->dbuf.mode)) & S_IFDIR)
  2285. -    || (*(finfo->name+strlen(finfo->name)-1) == '\\'))
  2286. -    {
  2287. -      finfo->mode=aDIR;
  2288. -    }
  2289. -  else
  2290. -    finfo->mode=0; /* we don't care about mode at the moment, we'll
  2291. -            * just make it a regular file */
  2292. -  /*
  2293. -   * Bug fix by richard@sj.co.uk
  2294. -   *
  2295. -   * REC: restore times correctly (as does tar)
  2296. -   * We only get the modification time of the file; set the creation time
  2297. -   * from the mod. time, and the access time to current time
  2298. -   */
  2299. -  finfo->mtime = finfo->ctime = strtol(hb->dbuf.mtime, NULL, 8);
  2300. -  finfo->atime = time(NULL);
  2301. -  finfo->size = unoct(hb->dbuf.size, sizeof(hb->dbuf.size));
  2302. -
  2303. -  return True;
  2304. -}
  2305. -
  2306. -static void unfixtarname(char *tptr, char *fp, int l)
  2307. -{
  2308. -  /* remove '.' from start of file name, convert from unix /'s to
  2309. -   * dos \'s in path. Kill any absolute path names.
  2310. -   */
  2311. -
  2312. -  if (*fp == '.') fp++;
  2313. -  if (*fp == '\\' || *fp == '/') fp++;
  2314. -
  2315. -#ifdef KANJI
  2316. -  while (l > 0) {
  2317. -    if (is_shift_jis (*fp)) {
  2318. -      *tptr++ = *fp++;
  2319. -      *tptr++ = *fp++;
  2320. -      l -= 2;
  2321. -    } else if (is_kana (*fp)) {
  2322. -      *tptr++ = *fp++;
  2323. -      l--;
  2324. -    } else if (*fp == '/') {
  2325. -      *tptr++ = '\\';
  2326. -      fp++;
  2327. -      l--;
  2328. -    } else {
  2329. -      *tptr++ = *fp++;
  2330. -      l--;
  2331. -    }
  2332. -  }
  2333. -#else
  2334. -  while (l--) { *tptr=(*fp == '/') ? '\\' : *fp; tptr++; fp++; }
  2335. -#endif
  2336. -}
  2337. -
  2338. -static long unoct(char *p, int ndgs)
  2339. -{
  2340. -  long value=0;
  2341. -  /* Converts octal string to long, ignoring any non-digit */
  2342. -
  2343. -  while (--ndgs)
  2344. -    {
  2345. -      if (isdigit(*p))
  2346. -        value = (value << 3) | (long) (*p - '0');
  2347. -
  2348. -      p++;
  2349. -    }
  2350. -
  2351. -  return value;
  2352. -}
  2353. -
  2354. -static BOOL smbcreat(file_info finfo, int *fnum, char *inbuf, char *outbuf)
  2355. -{
  2356. -  char *p;
  2357. -  /* *must* be called with buffer ready malloc'ed */
  2358. -  /* open remote file */
  2359. -  
  2360. -  memset(outbuf,0,smb_size);
  2361. -  set_message(outbuf,3,2 + strlen(finfo.name),True);
  2362. -  CVAL(outbuf,smb_com) = SMBcreate;
  2363. -  SSVAL(outbuf,smb_tid,cnum);
  2364. -  setup_pkt(outbuf);
  2365. -  
  2366. -  SSVAL(outbuf,smb_vwv0,finfo.mode);
  2367. -  put_dos_date3(outbuf,smb_vwv1,finfo.mtime);
  2368. -  
  2369. -  p = smb_buf(outbuf);
  2370. -  *p++ = 4;      
  2371. -  strcpy(p,finfo.name);
  2372. -  
  2373. -  send_smb(Client,outbuf);
  2374. -  receive_smb(Client,inbuf,CLIENT_TIMEOUT);
  2375. -  
  2376. -  if (CVAL(inbuf,smb_rcls) != 0)
  2377. -    {
  2378. -      DEBUG(0,("%s opening remote file %s\n",smb_errstr(inbuf),
  2379. -           finfo.name));
  2380. -      return 0;
  2381. -    }
  2382. -  
  2383. -  *fnum = SVAL(inbuf,smb_vwv0);
  2384. -  return True;
  2385. -}
  2386. -
  2387. -
  2388. -static BOOL smbwrite(int fnum, int n, int low, int high, int left,
  2389. -             char *bufferp, char *inbuf, char *outbuf)
  2390. -{
  2391. -  /* *must* be called with buffer ready malloc'ed */
  2392. -
  2393. -  memset(outbuf,0,smb_size);
  2394. -  set_message(outbuf,5,n + 3,True);
  2395. -  
  2396. -  memcpy(smb_buf(outbuf)+3, bufferp, n);
  2397. -  
  2398. -  set_message(outbuf,5,n + 3, False);
  2399. -  CVAL(outbuf,smb_com) = SMBwrite;
  2400. -  SSVAL(outbuf,smb_tid,cnum);
  2401. -  setup_pkt(outbuf);
  2402. -  
  2403. -  SSVAL(outbuf,smb_vwv0,fnum);
  2404. -  SSVAL(outbuf,smb_vwv1,n);
  2405. -  SIVAL(outbuf,smb_vwv2,low);
  2406. -  SSVAL(outbuf,smb_vwv4,left);
  2407. -  CVAL(smb_buf(outbuf),0) = 1;
  2408. -  SSVAL(smb_buf(outbuf),1,n);
  2409. -
  2410. -  send_smb(Client,outbuf); 
  2411. -  receive_smb(Client,inbuf,CLIENT_TIMEOUT);
  2412. -  
  2413. -  if (CVAL(inbuf,smb_rcls) != 0)
  2414. -    {
  2415. -      DEBUG(0,("%s writing remote file\n",smb_errstr(inbuf)));
  2416. -      return False;
  2417. -    }
  2418. -  
  2419. -  if (n != SVAL(inbuf,smb_vwv0))
  2420. -    {
  2421. -      DEBUG(0,("Error: only wrote %d bytes out of %d\n",
  2422. -           SVAL(inbuf,smb_vwv0), n));
  2423. -      return False;
  2424. -    }
  2425. -
  2426. -  return True;
  2427. -}
  2428. -
  2429. -static BOOL smbshut(file_info finfo, int fnum, char *inbuf, char *outbuf)
  2430. -{
  2431. -  /* *must* be called with buffer ready malloc'ed */
  2432. -
  2433. -  memset(outbuf,0,smb_size);
  2434. -  set_message(outbuf,3,0,True);
  2435. -  CVAL(outbuf,smb_com) = SMBclose;
  2436. -  SSVAL(outbuf,smb_tid,cnum);
  2437. -  setup_pkt(outbuf);
  2438. -  
  2439. -  SSVAL(outbuf,smb_vwv0,fnum);
  2440. -  put_dos_date3(outbuf,smb_vwv1,finfo.mtime);
  2441. -  
  2442. -  DEBUG(3,("Setting date to %s (0x%X)",
  2443. -       asctime(LocalTime(&finfo.mtime,GMT_TO_LOCAL)),
  2444. -       finfo.mtime));
  2445. -  
  2446. -  send_smb(Client,outbuf);
  2447. -  receive_smb(Client,inbuf,CLIENT_TIMEOUT);
  2448. -  
  2449. -  if (CVAL(inbuf,smb_rcls) != 0)
  2450. -    {
  2451. -      DEBUG(0,("%s closing remote file %s\n",smb_errstr(inbuf),
  2452. -           finfo.name));
  2453. -      return False;
  2454. -    }
  2455. -
  2456. -  return True;
  2457. -}
  2458. -
  2459. -
  2460. -static BOOL smbchkpath(char *fname, char *inbuf, char *outbuf)
  2461. -{
  2462. -  char *p;
  2463. -
  2464. -  memset(outbuf,0,smb_size);
  2465. -  set_message(outbuf,0,4 + strlen(fname),True);
  2466. -  CVAL(outbuf,smb_com) = SMBchkpth;
  2467. -  SSVAL(outbuf,smb_tid,cnum);
  2468. -  setup_pkt(outbuf);
  2469. -
  2470. -  p = smb_buf(outbuf);
  2471. -  *p++ = 4;
  2472. -  strcpy(p,fname);
  2473. +      get_total_size += finfo.size;
  2474.  
  2475. -  send_smb(Client,outbuf);
  2476. -  receive_smb(Client,inbuf,CLIENT_TIMEOUT);
  2477. +      /* Thanks to Carel-Jan Engel (ease@mail.wirehub.nl) for this one */
  2478. +      DEBUG(2,("(%g kb/s) (average %g kb/s)\n",
  2479. +           finfo.size / MAX(0.001, (1.024*this_time)),
  2480. +           get_total_size / MAX(0.001, (1.024*get_total_time_ms))));
  2481. +    }
  2482. +  
  2483. +  free(inbuf);free(outbuf);
  2484. +}
  2485.  
  2486. -  DEBUG(5,("smbchkpath: %s\n",smb_errstr(inbuf)));
  2487. +/****************************************************************************
  2488. +Append single file to tar file (or not)
  2489. +***************************************************************************/
  2490. +static void do_tar(file_info *finfo)
  2491. +{
  2492. +  pstring rname;
  2493.  
  2494. -  return(CVAL(inbuf,smb_rcls) == 0);
  2495. -}
  2496. +  if (strequal(finfo->name,".") || strequal(finfo->name,".."))
  2497. +    return;
  2498.  
  2499. +  /* Is it on the exclude list ? */
  2500. +  if (!tar_excl && clipn) {
  2501. +    pstring exclaim;
  2502.  
  2503. -static BOOL smbmkdir(char *fname, char *inbuf, char *outbuf)
  2504. -{
  2505. -  /* *must* be called with buffer ready malloc'ed */
  2506. -  char *p;
  2507. +    strcpy(exclaim, cur_dir);
  2508. +    *(exclaim+strlen(exclaim)-1)='\0';
  2509.  
  2510. -  memset(outbuf,0,smb_size);
  2511. -  set_message(outbuf,0,2 + strlen(fname),True);
  2512. -  
  2513. -  CVAL(outbuf,smb_com) = SMBmkdir;
  2514. -  SSVAL(outbuf,smb_tid,cnum);
  2515. -  setup_pkt(outbuf);
  2516. -  
  2517. -  p = smb_buf(outbuf);
  2518. -  *p++ = 4;      
  2519. -  strcpy(p,fname);
  2520. -  
  2521. -  send_smb(Client,outbuf);
  2522. -  receive_smb(Client,inbuf,CLIENT_TIMEOUT);
  2523. -  
  2524. -  if (CVAL(inbuf,smb_rcls) != 0)
  2525. -    {
  2526. -      DEBUG(0,("%s making remote directory %s\n",
  2527. -           smb_errstr(inbuf),fname));
  2528. -      return(False);
  2529. +    if (clipfind(cliplist, clipn, exclaim)) {
  2530. +      DEBUG(3,("Skipping directory %s\n", exclaim));
  2531. +      return;
  2532.      }
  2533.  
  2534. -  return(True);
  2535. -}
  2536. -
  2537. -static BOOL ensurepath(char *fname, char *inbuf, char *outbuf)
  2538. -{
  2539. -  /* *must* be called with buffer ready malloc'ed */
  2540. -  /* ensures path exists */
  2541. +    strcat(exclaim, "\\");
  2542. +    strcat(exclaim, finfo->name);
  2543.  
  2544. -  pstring partpath, ffname;
  2545. -  char *p=fname, *basehack;
  2546. +    if (clipfind(cliplist, clipn, exclaim)) {
  2547. +      DEBUG(3,("Skipping file %s\n", exclaim));
  2548. +      return;
  2549. +    }
  2550. +  }
  2551.  
  2552. -  *partpath = 0;
  2553. +  if (finfo->mode & aDIR)
  2554. +    {
  2555. +      pstring saved_curdir;
  2556. +      pstring mtar_mask;
  2557. +      char *inbuf,*outbuf;
  2558.  
  2559. -  /* fname copied to ffname so can strtok */
  2560. +      inbuf = (char *)malloc(BUFFER_SIZE + SAFETY_MARGIN);
  2561. +      outbuf = (char *)malloc(BUFFER_SIZE + SAFETY_MARGIN);
  2562.  
  2563. -  strcpy(ffname, fname);
  2564. +      if (!inbuf || !outbuf)
  2565. +    {
  2566. +      DEBUG(0,("out of memory\n"));
  2567. +      return;
  2568. +    }
  2569.  
  2570. -  /* do a `basename' on ffname, so don't try and make file name directory */
  2571. -  if ((basehack=strrchr(ffname, '\\')) == NULL)
  2572. -    return True;
  2573. -  else
  2574. -    *basehack='\0';
  2575. +      strcpy(saved_curdir,cur_dir);
  2576.  
  2577. -  p=strtok(ffname, "\\");
  2578. +      strcat(cur_dir,finfo->name);
  2579. +      strcat(cur_dir,"\\");
  2580.  
  2581. -  while (p)
  2582. +      /* write a tar directory, don't bother with mode - just set it to
  2583. +       * 40755 */
  2584. +      writetarheader(tarhandle, cur_dir, 0, finfo->mtime, "040755 \0");
  2585. +      strcpy(mtar_mask,cur_dir);
  2586. +      strcat(mtar_mask,"*");
  2587. +      
  2588. +      do_dir((char *)inbuf,(char *)outbuf,mtar_mask,attribute,do_tar,recurse);
  2589. +      strcpy(cur_dir,saved_curdir);
  2590. +      free(inbuf);free(outbuf);
  2591. +    }
  2592. +  else
  2593.      {
  2594. -      strcat(partpath, p);
  2595. +      strcpy(rname,cur_dir);
  2596. +      strcat(rname,finfo->name);
  2597. +      do_atar(rname,finfo->name,finfo);
  2598. +    }
  2599. +}
  2600.  
  2601. -      if (!smbchkpath(partpath, inbuf, outbuf)) {
  2602. -    if (!smbmkdir(partpath, inbuf, outbuf))
  2603. -      {
  2604. -        DEBUG(0, ("Error mkdirhiering\n"));
  2605. -        return False;
  2606. -      }
  2607. -    else
  2608. -      DEBUG(3, ("mkdirhiering %s\n", partpath));
  2609. +/****************************************************************************
  2610. +Convert from UNIX to DOS file names
  2611. +***************************************************************************/
  2612. +static void unfixtarname(char *tptr, char *fp, int l)
  2613. +{
  2614. +  /* remove '.' from start of file name, convert from unix /'s to
  2615. +   * dos \'s in path. Kill any absolute path names.
  2616. +   */
  2617.  
  2618. -      }
  2619. +  if (*fp == '.') fp++;
  2620. +  if (*fp == '\\' || *fp == '/') fp++;
  2621.  
  2622. -      strcat(partpath, "\\");
  2623. -      p = strtok(NULL,"/\\");
  2624. +#ifdef KANJI
  2625. +  while (l > 0) {
  2626. +    if (is_shift_jis (*fp)) {
  2627. +      *tptr++ = *fp++;
  2628. +      *tptr++ = *fp++;
  2629. +      l -= 2;
  2630. +    } else if (is_kana (*fp)) {
  2631. +      *tptr++ = *fp++;
  2632. +      l--;
  2633. +    } else if (*fp == '/') {
  2634. +      *tptr++ = '\\';
  2635. +      fp++;
  2636. +      l--;
  2637. +    } else {
  2638. +      *tptr++ = *fp++;
  2639. +      l--;
  2640.      }
  2641. -
  2642. -    return True;
  2643. +  }
  2644. +#else
  2645. +  while (l--) { *tptr=(*fp == '/') ? '\\' : *fp; tptr++; fp++; }
  2646. +#endif
  2647.  }
  2648.  
  2649.  static void do_tarput()
  2650. @@ -1114,8 +1206,10 @@
  2651.    int nread=0, bufread;
  2652.    char *inbuf,*outbuf; 
  2653.    int fsize=0;
  2654. -  
  2655. +  int fnum;
  2656.    struct timeval tp_start;
  2657. +  BOOL tskip=False;       /* We'll take each file as it comes */
  2658. +
  2659.    GetTimeOfDay(&tp_start);
  2660.    
  2661.    inbuf = (char *)malloc(BUFFER_SIZE + SAFETY_MARGIN);
  2662. @@ -1129,16 +1223,47 @@
  2663.    
  2664.    /*
  2665.     * Must read in tbufsiz dollops
  2666. -   * - this is crude as should detect
  2667.     */
  2668. -  
  2669. -  while ((bufread=read(tarhandle, tarbuf, tbufsiz))) {
  2670. +
  2671. +  /* These should be the only reads in clitar.c */
  2672. +  while ((bufread=read(tarhandle, tarbuf, tbufsiz))>0) {
  2673.      char *bufferp, *endofbuffer;
  2674. -    int chunk, fnum;
  2675. -    
  2676. +    int chunk;
  2677. +
  2678. +    /* Code to handle a short read.
  2679. +     * We always need a TBLOCK full of stuff
  2680. +     */
  2681. +    if (bufread % TBLOCK) {
  2682. +      int lchunk=TBLOCK-(bufread % TBLOCK);
  2683. +      int lread;
  2684. +
  2685. +      /* It's a shorty - a short read that is */
  2686. +      DEBUG(3, ("Short read, read %d so far (need %d)\n", bufread, lchunk));
  2687. +
  2688. +      while ((lread=read(tarhandle, tarbuf+bufread, lchunk))>0) {
  2689. +    bufread+=lread;
  2690. +    if (!(lchunk-=lread)) break;
  2691. +      }
  2692. +
  2693. +      /* If we've reached EOF then that must be a short file */
  2694. +      if (lread<=0) break;
  2695. +    }
  2696. +
  2697.      bufferp=tarbuf; 
  2698.      endofbuffer=tarbuf+bufread;
  2699. -    
  2700. +
  2701. +    if (tskip) {
  2702. +      if (fsize<bufread) {
  2703. +    tskip=False;
  2704. +    bufferp+=fsize;
  2705. +    fsize=0;
  2706. +      } else {
  2707. +    if (fsize==bufread) tskip=False;
  2708. +    fsize-=bufread;
  2709. +    continue;
  2710. +      }
  2711. +    }
  2712. +
  2713.      do {
  2714.        if (!fsize)
  2715.      {
  2716. @@ -1162,6 +1287,25 @@
  2717.            break;
  2718.          }
  2719.  
  2720. +      tskip=clipn
  2721. +        && (clipfind(cliplist, clipn, finfo.name) ^ tar_excl);
  2722. +      if (tskip) {
  2723. +        bufferp+=TBLOCK;
  2724. +        if (finfo.mode & aDIR)
  2725. +          continue;
  2726. +        else if ((fsize=finfo.size) % TBLOCK) {
  2727. +          fsize+=TBLOCK-(fsize%TBLOCK);
  2728. +        }
  2729. +        if (fsize<endofbuffer-bufferp) {
  2730. +          bufferp+=fsize;
  2731. +          fsize=0;
  2732. +          continue;
  2733. +        } else {
  2734. +          fsize-=endofbuffer-bufferp;
  2735. +          break;
  2736. +        }
  2737. +      }
  2738. +
  2739.        if (finfo.mode & aDIR)
  2740.          {
  2741.            if (!smbchkpath(finfo.name, inbuf, outbuf)
  2742. @@ -1187,13 +1331,13 @@
  2743.            free(inbuf);free(outbuf);
  2744.            return;
  2745.          }
  2746. -      
  2747. +
  2748.        DEBUG(0,("restore tar file %s of size %d bytes\n",
  2749.             finfo.name,finfo.size));
  2750.  
  2751.        nread=0;
  2752.        if ((bufferp+=TBLOCK) >= endofbuffer) break;      
  2753. -    } /* if nread */
  2754. +    } /* if (!fsize) */
  2755.      
  2756.        /* write out the file in chunk sized chunks - don't
  2757.         * go past end of buffer though */
  2758. @@ -1238,20 +1382,20 @@
  2759.      }
  2760.      } while (bufferp < endofbuffer);
  2761.    }
  2762. -  if (ntarf) 
  2763. -    DEBUG(0, ("premature eof on tar file ?\n"));
  2764. -  else
  2765. -    DEBUG(0,("total of %d tar files restored to share\n", ntarf));
  2766. -  
  2767. +
  2768. +  DEBUG(0, ("premature eof on tar file ?\n"));
  2769. +  DEBUG(0,("total of %d tar files restored to share\n", ntarf));
  2770. +
  2771.    free(inbuf); free(outbuf);
  2772.  }
  2773.  
  2774.  /*
  2775. - * samba commands
  2776. + * samba interactive commands
  2777.   */
  2778.  
  2779. -/* blocksize command */
  2780. -
  2781. +/****************************************************************************
  2782. +Blocksize command
  2783. +***************************************************************************/
  2784.  void cmd_block(void)
  2785.  {
  2786.    fstring buf;
  2787. @@ -1274,6 +1418,9 @@
  2788.    DEBUG(2,("blocksize is now %d\n", blocksize));
  2789.  }
  2790.  
  2791. +/****************************************************************************
  2792. +command to set incremental / reset mode
  2793. +***************************************************************************/
  2794.  void cmd_tarmode(void)
  2795.  {
  2796.    fstring buf;
  2797. @@ -1295,8 +1442,9 @@
  2798.          tar_reset ? "reset" : "noreset"));
  2799.  }
  2800.  
  2801. -/* freebie crude attrib command */
  2802. -
  2803. +/****************************************************************************
  2804. +Feeble attrib command
  2805. +***************************************************************************/
  2806.  void cmd_setmode(void)
  2807.  {
  2808.    char *q;
  2809. @@ -1349,93 +1497,217 @@
  2810.    (void) do_setrattr(fname, attra[ATTRRESET], ATTRRESET);
  2811.  }
  2812.  
  2813. -/*
  2814. - * do a tar command
  2815. - */
  2816. -
  2817. +/****************************************************************************
  2818. +Principal command for creating / extracting
  2819. +***************************************************************************/
  2820.  void cmd_tar(char *inbuf, char *outbuf)
  2821.  {
  2822. -  int attribute = aDIR | aSYSTEM | aHIDDEN;
  2823. -  pstring ffname, tarmac;
  2824.    fstring buf;
  2825. -  char *p = buf;
  2826. +  char **argl;
  2827. +  int argcl;
  2828.  
  2829.    if (!next_token(NULL,buf,NULL))
  2830.      {
  2831. -      DEBUG(0,("tar [c|x] <filename>\n"));
  2832. +      DEBUG(0,("tar <c|x>[IXbga] <filename>\n"));
  2833.        return;
  2834.      }
  2835.  
  2836. -  if (*p == 'c') {
  2837. -    if (!next_token(NULL,buf,NULL))
  2838. -      {
  2839. -    DEBUG(0,("tar [c|x] <filename> [<tar mask>]\n"));
  2840. -    return;
  2841. -      }
  2842. -    
  2843. -    strcpy(ffname,p);
  2844. -    
  2845. -    if(!strcmp(ffname,"-"))
  2846. -      tarhandle = fileno(stdout);
  2847. -    else 
  2848. -      tarhandle = creat(ffname,0644);
  2849. -    
  2850. -    if (tarhandle < 0)
  2851. -      {
  2852. -    DEBUG(0,("Error opening local file %s\n",ffname));
  2853. -    return;
  2854. -      }
  2855. -    
  2856. -    initarbuf();
  2857. +  argl=toktocliplist(&argcl, NULL);
  2858. +  if (!tar_parseargs(argcl, argl, buf, 0))
  2859. +    return;
  2860. +
  2861. +  process_tar(inbuf, outbuf);
  2862. +
  2863. +  free(argl);
  2864. +}
  2865. +
  2866. +/****************************************************************************
  2867. +Command line (option) version
  2868. +***************************************************************************/
  2869. +int process_tar(char *inbuf, char *outbuf)
  2870. +{
  2871. +  initarbuf();
  2872. +  switch(tar_type) {
  2873. +  case 'x':
  2874. +    do_tarput();
  2875. +    free(tarbuf);
  2876. +    close(tarhandle);
  2877. +    break;
  2878. +  case 'r':
  2879. +  case 'c':
  2880. +    if (clipn && tar_excl) {
  2881. +      int i;
  2882. +      pstring tarmac;
  2883.  
  2884. -    strcpy(tarmac,cur_dir);
  2885. -    if (next_token(NULL,buf,NULL))
  2886. -      do {
  2887. -    if(tarmac[strlen(tarmac)-1]!='\\')
  2888. -      strcat(tarmac,"\\");
  2889. +      for (i=0; i<clipn; i++) {
  2890. +    DEBUG(0,("arg %d = %s\n", i, cliplist[i]));
  2891. +
  2892. +    if (*(cliplist[i]+strlen(cliplist[i])-1)=='\\') {
  2893. +      *(cliplist[i]+strlen(cliplist[i])-1)='\0';
  2894. +    }
  2895.      
  2896. -    if (*p == '\\')
  2897. -      strcpy(tarmac,p);
  2898. -    else
  2899. -      strcat(tarmac,p);
  2900. -      } while (next_token(NULL,buf,NULL));
  2901. -    else
  2902. -      strcat(tarmac,"*.*");
  2903. -    
  2904. -    do_dir((char *)inbuf,(char *)outbuf,tarmac,attribute,do_tar,recurse);
  2905. +    if (strrchr(cliplist[i], '\\')) {
  2906. +      pstring saved_dir;
  2907. +      
  2908. +      strcpy(saved_dir, cur_dir);
  2909. +      
  2910. +      if (*cliplist[i]=='\\') {
  2911. +        strcpy(tarmac, cliplist[i]);
  2912. +      } else {
  2913. +        strcpy(tarmac, cur_dir);
  2914. +        strcat(tarmac, cliplist[i]);
  2915. +      }
  2916. +      strcpy(cur_dir, tarmac);
  2917. +      *(strrchr(cur_dir, '\\')+1)='\0';
  2918. +
  2919. +      do_dir((char *)inbuf,(char *)outbuf,tarmac,attribute,do_tar,recurse);
  2920. +      strcpy(cur_dir,saved_dir);
  2921. +    } else {
  2922. +      strcpy(tarmac, cur_dir);
  2923. +      strcat(tarmac, cliplist[i]);
  2924. +      do_dir((char *)inbuf,(char *)outbuf,tarmac,attribute,do_tar,recurse);
  2925. +    }
  2926. +      }
  2927. +    } else {
  2928. +      pstring mask;
  2929. +      strcpy(mask,cur_dir);
  2930. +      strcat(mask,"\\*");
  2931. +      do_dir((char *)inbuf,(char *)outbuf,mask,attribute,do_tar,recurse);
  2932. +    }
  2933.      
  2934.      if (ntarf) dotareof(tarhandle);
  2935.      close(tarhandle);
  2936.      free(tarbuf);
  2937.      
  2938.      DEBUG(0, ("tar: dumped %d tar files\n", ntarf));
  2939. +    break;
  2940.    }
  2941. -  else if (*p=='x') {
  2942. -    if (!next_token(NULL,buf,NULL))
  2943. -      {
  2944. -    DEBUG(0,("tar [c|x] <filename> [<tar mask>]\n"));
  2945. -    return;
  2946. +
  2947. +  return(0);
  2948. +}
  2949. +
  2950. +/****************************************************************************
  2951. +Find a token (filename) in a clip list
  2952. +***************************************************************************/
  2953. +int clipfind(char **aret, int ret, char *tok)
  2954. +{
  2955. +  if (aret==NULL) return 0;
  2956. +
  2957. +  /* ignore leading slashes or dots in token */
  2958. +  while(strchr("/\\.", *tok)) tok++;
  2959. +
  2960. +  while(ret--) {
  2961. +    char *pkey=*aret++;
  2962. +
  2963. +    /* ignore leading slashes or dots in list */
  2964. +    while(strchr("/\\.", *pkey)) pkey++;
  2965. +
  2966. +    if (!strslashcmp(pkey, tok)) return 1;
  2967. +  }
  2968. +
  2969. +  return 0;
  2970. +}
  2971. +
  2972. +/****************************************************************************
  2973. +Parse tar arguments. Sets tar_type, tar_excl, etc.
  2974. +***************************************************************************/
  2975. +int tar_parseargs(int argc, char *argv[], char *Optarg, int Optind)
  2976. +{
  2977. +  char tar_clipfl='\0';
  2978. +
  2979. +  /* Reset back to defaults - could be from interactive version 
  2980. +   * reset mode and archive mode left as they are though
  2981. +   */
  2982. +  tar_type='\0';
  2983. +  tar_excl=True;
  2984. +
  2985. +  while (*Optarg) 
  2986. +    switch(*Optarg++) {
  2987. +    case 'c':
  2988. +      tar_type='c';
  2989. +      break;
  2990. +    case 'x':
  2991. +      if (tar_type=='c') {
  2992. +    printf("Tar must be followed by only one of c or x.\n");
  2993. +    return 0;
  2994.        }
  2995. -    
  2996. -    strcpy(ffname,p);
  2997. -    
  2998. -    if(!strcmp(ffname,"-"))
  2999. -      tarhandle = fileno(stdin);
  3000. -    else 
  3001. -      if ((tarhandle = open(ffname,O_RDONLY)) == -1)
  3002. -    {
  3003. -      DEBUG(0,("Error opening local file %s\n",ffname));
  3004. -      return;
  3005. +      tar_type='x';
  3006. +      break;
  3007. +    case 'b':
  3008. +      if (Optind>=argc || !(blocksize=atoi(argv[Optind]))) {
  3009. +    DEBUG(0,("Option b must be followed by valid blocksize\n"));
  3010. +    return 0;
  3011. +      } else {
  3012. +    Optind++;
  3013. +      }
  3014. +      break;
  3015. +    case 'g':
  3016. +      tar_inc=True;
  3017. +      break;
  3018. +    case 'N':
  3019. +      if (Optind>=argc) {
  3020. +    DEBUG(0,("Option N must be followed by valid file name\n"));
  3021. +    return 0;
  3022. +      } else {
  3023. +    struct stat stbuf;
  3024. +    extern time_t newer_than;
  3025. +    
  3026. +    if (sys_stat(argv[Optind], &stbuf) == 0) {
  3027. +      newer_than = stbuf.st_mtime;
  3028. +      DEBUG(1,("Getting files newer than %s",
  3029. +           asctime(LocalTime(&newer_than,GMT_TO_LOCAL))));
  3030. +      Optind++;
  3031. +    } else {
  3032. +      DEBUG(0,("Error setting newer-than time\n"));
  3033. +      return 0;
  3034.      }
  3035. +      }
  3036. +      break;
  3037. +    case 'a':
  3038. +      tar_reset=True;
  3039. +      break;
  3040. +    case 'I':
  3041. +      if (tar_clipfl) {
  3042. +    DEBUG(0,("Only one of I,X must be specified\n"));
  3043. +    return 0;
  3044. +      }
  3045. +      tar_clipfl='I';
  3046. +      break;
  3047. +    case 'X':
  3048. +      if (tar_clipfl) {
  3049. +    DEBUG(0,("Only one of I,X must be specified\n"));
  3050. +    return 0;
  3051. +      }
  3052. +      tar_clipfl='X';
  3053. +      break;
  3054. +    default:
  3055. +      DEBUG(0,("Unknown tar option\n"));
  3056. +      return 0;
  3057. +    }
  3058.  
  3059. -    initarbuf();
  3060. +  if (!tar_type) {
  3061. +    printf("Option T must be followed by one of c or x.\n");
  3062. +    return 0;
  3063. +  }
  3064.  
  3065. -    do_tarput();
  3066. +  if (Optind>=argc || !strcmp(argv[Optind], "-")) {
  3067. +    /* Sets tar handle to either 0 or 1, as appropriate */
  3068. +    tarhandle=(tar_type=='c');
  3069. +  } else {
  3070. +    tar_excl=tar_clipfl!='X';
  3071. +    
  3072. +    if (Optind+1<argc) {
  3073. +      cliplist=argv+Optind+1;
  3074. +      clipn=argc-Optind-1;
  3075. +    }
  3076.  
  3077. -    free(tarbuf);
  3078. -    close(tarhandle);
  3079. +    if ((tar_type=='x' && (tarhandle = open(argv[Optind], O_RDONLY)) == -1)
  3080. +    || (tar_type=='c' && (tarhandle=creat(argv[Optind], 0644)) < 0))
  3081. +      {
  3082. +    DEBUG(0,("Error opening local file %s\n",argv[Optind]));
  3083. +    return(0);
  3084. +      }
  3085.    }
  3086. -  else
  3087. -    DEBUG(0,("tar [c|x] <filename>\n"));
  3088. -}
  3089.  
  3090. +  return 1;
  3091. +}
  3092. diff -u -r --new-file last-version/source/includes.h samba-1.9.16alpha1/source/includes.h
  3093. --- last-version/source/includes.h    Mon Jan 15 19:15:36 1996
  3094. +++ samba-1.9.16alpha1/source/includes.h    Thu Feb 29 00:12:08 1996
  3095. @@ -104,6 +104,10 @@
  3096.  #define NO_NETIFH
  3097.  #endif
  3098.  
  3099. +#ifdef LYNX
  3100. +#define NO_SYSMOUNTH
  3101. +#endif
  3102. +
  3103.  
  3104.  #if (defined(SHADOW_PWD)||defined(OSF1_ENH_SEC)||defined(SecureWare)||defined(PWDAUTH))
  3105.  #define PASSWORD_LENGTH 16
  3106. @@ -196,6 +200,16 @@
  3107.  
  3108.  /* this might be different on different systems */
  3109.  #ifdef QUOTAS 
  3110. +#ifdef LINUX
  3111. +#ifdef __KERNEL__
  3112. +#undef __KERNEL__
  3113. +#include <sys/quota.h>
  3114. +#define __KERNEL__
  3115. +#else
  3116. +#include <sys/quota.h>
  3117. +#endif
  3118. +#include <mntent.h>
  3119. +#else
  3120.  #include <sys/quota.h>
  3121.  #ifndef CRAY
  3122.  #include <devnm.h>
  3123. @@ -203,6 +217,7 @@
  3124.  #include <mntent.h>
  3125.  #endif
  3126.  #endif
  3127. +#endif
  3128.  
  3129.  #ifdef SYSLOG
  3130.  #include <syslog.h>
  3131. @@ -393,6 +408,7 @@
  3132.  #define SIGNAL_CAST (void (*)(int))
  3133.  #define USE_STATVFS
  3134.  #define USE_GETCWD
  3135. +#define USE_SETSID
  3136.  #endif
  3137.  
  3138.  
  3139. @@ -415,6 +431,7 @@
  3140.  #include <prot.h>
  3141.  #include <unistd.h>
  3142.  #define PASSWORD_LENGTH 16
  3143. +#define NEED_AUTH_PARAMETERS
  3144.  #endif  /* OSF1_ENH_SEC */
  3145.  #endif
  3146.  
  3147. @@ -494,6 +511,11 @@
  3148.  #include <sys/types.h>
  3149.  #include <sys/termios.h>
  3150.  #include <netinet/tcp.h>
  3151. +#ifdef HPUX_10_TRUSTED
  3152. +#include <hpsecurity.h>
  3153. +#include <prot.h>
  3154. +#define NEED_AUTH_PARAMETERS
  3155. +#endif
  3156.  #define SIGNAL_CAST (void (*)(__harg))
  3157.  #define SELECT_CAST (int *)
  3158.  #define SYSV
  3159. @@ -555,6 +577,7 @@
  3160.  #define gid_t int
  3161.  #define SIGNAL_CAST (void (*)(int))
  3162.  #define WAIT3_CAST1 (union wait *)
  3163. +#define HAVE_GMTOFF
  3164.  #endif
  3165.  
  3166.  
  3167. @@ -765,9 +788,7 @@
  3168.  #define        gid_t           int
  3169.  #define        mode_t          int
  3170.  #define        ptrdiff_t       int
  3171. -
  3172.  #define HAVE_GETGRNAM  0
  3173. -
  3174.  #define NO_EID
  3175.  #define NO_FSYNC
  3176.  #define        NO_FTRUNCATE
  3177. @@ -834,9 +855,28 @@
  3178.  #endif
  3179.  
  3180.  
  3181. +#ifdef LYNX
  3182. +#define SIGNAL_CAST (void (*)())
  3183. +#define WAIT3_CAST1 (union wait *)
  3184. +#define STATFS4
  3185. +#include <fcntl.h>
  3186. +#include <resource.h>
  3187. +#include <stat.h>
  3188. +#include <string.h>
  3189. +#include <dirent.h>
  3190. +#include <sys/statfs.h>
  3191. +#define USE_GETCWD
  3192. +#define USE_GETSID
  3193. +#endif
  3194. +
  3195. +
  3196.  /*******************************************************************
  3197.  end of the platform specific sections
  3198.  ********************************************************************/
  3199. +
  3200. +#ifdef SecureWare
  3201. +#define NEED_AUTH_PARAMETERS
  3202. +#endif
  3203.  
  3204.  #ifdef REPLACE_GETPASS
  3205.  extern char    *getsmbpass(char *);
  3206. diff -u -r --new-file last-version/source/installman.sh samba-1.9.16alpha1/source/installman.sh
  3207. --- last-version/source/installman.sh    Sat Nov 18 20:36:53 1995
  3208. +++ samba-1.9.16alpha1/source/installman.sh    Sat Feb 24 19:04:53 1996
  3209. @@ -1,5 +1,6 @@
  3210.  #!/bin/sh
  3211.  MANDIR=$1
  3212. +SRCDIR=$2
  3213.  
  3214.  echo Installing man pages in $MANDIR
  3215.  
  3216. @@ -13,10 +14,11 @@
  3217.  fi
  3218.  done
  3219.  
  3220. -cp ../docs/*.1 $MANDIR/man1
  3221. -cp ../docs/*.5 $MANDIR/man5
  3222. -cp ../docs/*.8 $MANDIR/man8
  3223. -cp ../docs/*.7 $MANDIR/man7
  3224. +cp $SRCDIR../docs/*.1 $MANDIR/man1
  3225. +cp $SRCDIR../docs/*.5 $MANDIR/man5
  3226. +cp $SRCDIR../docs/*.8 $MANDIR/man8
  3227. +cp $SRCDIR../docs/*.7 $MANDIR/man7
  3228. +echo Setting permissions on man pages
  3229.  chmod 0644 $MANDIR/man1/smbstatus.1
  3230.  chmod 0644 $MANDIR/man1/smbclient.1
  3231.  chmod 0644 $MANDIR/man1/smbrun.1
  3232. @@ -28,5 +30,6 @@
  3233.  chmod 0644 $MANDIR/man8/smbd.8
  3234.  chmod 0644 $MANDIR/man8/nmbd.8
  3235.  
  3236. +echo Man pages installed
  3237.  exit 0
  3238.  
  3239. diff -u -r --new-file last-version/source/ipc.c samba-1.9.16alpha1/source/ipc.c
  3240. --- last-version/source/ipc.c    Mon Jan 15 16:24:54 1996
  3241. +++ samba-1.9.16alpha1/source/ipc.c    Sun Feb 25 13:10:25 1996
  3242. @@ -35,6 +35,7 @@
  3243.  extern int DEBUGLEVEL;
  3244.  extern int maxxmit;
  3245.  extern files_struct Files[];
  3246. +extern connection_struct Connections[];
  3247.  
  3248.  extern fstring local_machine;
  3249.  
  3250. @@ -417,7 +418,6 @@
  3251.    PACK(desc,t,v);
  3252.  }
  3253.  
  3254. -
  3255.  static void PackDriverData(struct pack_desc* desc)
  3256.  {
  3257.    char drivdata[4+4+32];
  3258. @@ -667,7 +667,7 @@
  3259.      return False;
  3260.    queuecnt = 0;
  3261.    for (i = 0; i < services; i++)
  3262. -    if (lp_print_ok(i) && lp_browseable(i))
  3263. +    if (lp_snum_ok(i) && lp_print_ok(i) && lp_browseable(i))
  3264.        queuecnt++;
  3265.    if (uLevel > 0) {
  3266.      queue = (print_queue_struct**)malloc(queuecnt*sizeof(print_queue_struct*));
  3267. @@ -678,7 +678,7 @@
  3268.      subcnt = 0;
  3269.      n = 0;
  3270.      for (i = 0; i < services; i++)
  3271. -      if (lp_print_ok(i) && lp_browseable(i)) {
  3272. +      if (lp_snum_ok(i) && lp_print_ok(i) && lp_browseable(i)) {
  3273.       subcntarr[n] = get_printqueue(i,cnum,&queue[n],&status[n]);
  3274.       subcnt += subcntarr[n];
  3275.       n++;
  3276. @@ -692,7 +692,7 @@
  3277.      n = 0;
  3278.      succnt = 0;
  3279.      for (i = 0; i < services; i++)
  3280. -      if (lp_print_ok(i) && lp_browseable(i)) {
  3281. +      if (lp_snum_ok(i) && lp_print_ok(i) && lp_browseable(i)) {
  3282.      fill_printq_info(cnum,i,uLevel,&desc,subcntarr[n],queue[n],&status[n]);
  3283.      n++;
  3284.      if (desc.errcode == NERR_Success) succnt = n;
  3285. @@ -737,19 +737,58 @@
  3286.    return True;
  3287.  }
  3288.  
  3289. -struct server_info_struct {
  3290. +/* used for server information: client, nameserv and ipc */
  3291. +struct srv_info_struct
  3292. +{
  3293.    fstring name;
  3294.    uint32 type;
  3295.    fstring comment;
  3296. +  fstring domain; /* used ONLY in ipc.c NOT namework.c */
  3297. +  BOOL server_added; /* used ONLY in ipc.c NOT namework.c */
  3298.  };
  3299.  
  3300. +/*******************************************************************
  3301. +  filter out unwanted server info 
  3302. +  ******************************************************************/
  3303. +static BOOL filter_server_info(struct srv_info_struct *server, 
  3304. +                   char *domain)
  3305. +{
  3306. +  if (*domain)
  3307. +    return(strequal(domain, server->domain));
  3308. +  
  3309. +  return (True); /* be indiscriminate: get all servers! */
  3310. +}
  3311. +
  3312. +/*******************************************************************
  3313. +  find server in the files saved by nmbd. Return True if we find it.
  3314. +  ******************************************************************/
  3315. +static BOOL find_server(struct srv_info_struct *servers, int num_servers,
  3316. +         char *domain, char *name)
  3317. +{
  3318. +  int count;
  3319. +
  3320. +  if (!servers || num_servers == 0) return (False);
  3321. +
  3322. +  for (count = 0; count < num_servers; count++)    {
  3323. +    struct srv_info_struct *s;
  3324. +
  3325. +    s = &servers[count];
  3326. +
  3327. +    if (strequal(name, s->name)) {
  3328. +      StrnCpy(domain, s->domain, sizeof(pstring)-1);
  3329. +      return (True);
  3330. +    }
  3331. +  }
  3332. +  return (False);
  3333. +}
  3334. +
  3335.  
  3336.  /*******************************************************************
  3337.    get server info lists from the files saved by nmbd. Return the
  3338.    number of entries
  3339.    ******************************************************************/
  3340. -static int get_server_info(uint32 servertype,
  3341. -               struct server_info_struct **servers)
  3342. +static int get_server_info(uint32 servertype, 
  3343. +               struct srv_info_struct **servers)
  3344.  {
  3345.    FILE *f;
  3346.    pstring fname;
  3347. @@ -768,35 +807,48 @@
  3348.      DEBUG(4,("Can't open %s - %s\n",fname,strerror(errno)));
  3349.      return(0);
  3350.    }
  3351. +  if (servertype == SV_TYPE_ALL) servertype &= ~SV_TYPE_DOMAIN_ENUM;
  3352.  
  3353. -  if (servertype == SV_TYPE_ALL)
  3354. -    servertype &= ~SV_TYPE_DOMAIN_ENUM;
  3355. -
  3356. -  while (!feof(f)) {
  3357. +  while (!feof(f))
  3358. +  {
  3359.      fstring stype;
  3360. -    struct server_info_struct *s;
  3361. +    struct srv_info_struct *s;
  3362.      char *ptr = line;
  3363.      *ptr = 0;
  3364. +
  3365.      fgets(line,sizeof(line)-1,f);
  3366.      if (!*line) continue;
  3367.  
  3368.      if (count == alloced) {
  3369.        alloced += 10;
  3370. -      (*servers) = (struct server_info_struct *)
  3371. +      (*servers) = (struct srv_info_struct *)
  3372.      Realloc(*servers,sizeof(**servers)*alloced);
  3373.        if (!(*servers)) return(0);
  3374.        bzero((char *)((*servers)+count),sizeof(**servers)*(alloced-count));
  3375.      }
  3376.      s = &(*servers)[count];
  3377.  
  3378. -    if (!next_token(&ptr,s->name,NULL)) continue;
  3379. -    if (!next_token(&ptr,stype,NULL)) continue;
  3380. -    if (!next_token(&ptr,s->comment,NULL)) continue;
  3381. +    s->server_added = True;
  3382. +
  3383. +    if (!next_token(&ptr,s->name   , NULL)) continue;
  3384. +    if (!next_token(&ptr,stype     , NULL)) continue;
  3385. +    if (!next_token(&ptr,s->comment, NULL)) continue;
  3386. +    if (!next_token(&ptr,s->domain , NULL)) {
  3387. +      /* this allows us to cop with an old nmbd */
  3388. +      strcpy(s->domain,my_workgroup()); 
  3389. +    }
  3390. +
  3391.      if (sscanf(stype,"%X",&s->type) != 1) continue;
  3392.  
  3393. -    if (!(servertype & s->type) || 
  3394. -    ((s->type&SV_TYPE_DOMAIN_ENUM) && 
  3395. -     !(servertype&SV_TYPE_DOMAIN_ENUM))) continue;
  3396. +    /* doesn't match up: don't want it */
  3397. +    if (!(servertype & s->type)) continue;
  3398. +
  3399. +    /* server entry is a domain, we haven't asked for domains: don't want it */
  3400. +    if ((s->type&SV_TYPE_DOMAIN_ENUM) && !(servertype&SV_TYPE_DOMAIN_ENUM))
  3401. +      continue;
  3402. +
  3403. +    DEBUG(4,("Server %20s %8x %25s %15s\n",
  3404. +         s->name, stype, s->comment, s->domain));
  3405.  
  3406.      count++;
  3407.    }
  3408. @@ -808,9 +860,9 @@
  3409.  /*******************************************************************
  3410.    fill in a server info structure
  3411.    ******************************************************************/
  3412. -static int fill_server_info(struct server_info_struct *service,
  3413. -                int uLevel,char **buf, int *buflen,
  3414. -                char **stringbuf, int *stringspace, char *baseaddr)
  3415. +static int fill_srv_info(struct srv_info_struct *service, 
  3416. +             int uLevel, char **buf, int *buflen, 
  3417. +             char **stringbuf, int *stringspace, char *baseaddr)
  3418.  {
  3419.    int struct_len;
  3420.    char* p;
  3421. @@ -888,10 +940,9 @@
  3422.    view list of servers available (or possibly domains). The info is
  3423.    extracted from lists saved by nmbd on the local host
  3424.    ****************************************************************************/
  3425. -static BOOL api_RNetServerEnum(int cnum,int uid, char *param,char *data,
  3426. -                   int mdrcnt,int mprcnt,
  3427. -                   char **rdata,char **rparam,
  3428. -                   int *rdata_len,int *rparam_len)
  3429. +static BOOL api_RNetServerEnum(int cnum, int uid, char *param, char *data,
  3430. +                   int mdrcnt, int mprcnt, char **rdata, 
  3431. +                   char **rparam, int *rdata_len, int *rparam_len)
  3432.  {
  3433.    char *str1 = param+2;
  3434.    char *str2 = skip_string(str1,1);
  3435. @@ -902,37 +953,81 @@
  3436.    char *p2;
  3437.    int data_len, fixed_len, string_len;
  3438.    int f_len, s_len;
  3439. -  struct server_info_struct *servers=NULL;
  3440. +  struct srv_info_struct *servers=NULL;
  3441.    int counted=0,total=0;
  3442.    int i;
  3443. +  fstring domain;
  3444. +  BOOL domain_request = (servertype & SV_TYPE_DOMAIN_ENUM) &&
  3445. +                       !(servertype == SV_TYPE_ALL);
  3446. +
  3447. +  domain[0] = 0;
  3448. +  p += 8;
  3449.  
  3450.    if (!prefix_ok(str1,"WrLehD")) return False;
  3451.    if (!check_server_info(uLevel,str2)) return False;
  3452.    
  3453. +  DEBUG(4, ("server request level: %s\n", str2));
  3454. +
  3455. +  if (strcmp(str1, "WrLehDO") == 0)
  3456. +  {
  3457. +    /* asking for servers. we will have to work out which workgroup was
  3458. +       requested, as we maintain lists for multiple workgroups */
  3459. +  }
  3460. +  else if (strcmp(str1, "WrLehDz") == 0)
  3461. +  {
  3462. +    /* asking for a specific workgroup */
  3463. +    StrnCpy(domain, p, sizeof(fstring)-1);
  3464. +  }
  3465. +
  3466.    if (lp_browse_list())
  3467. +  {
  3468.      total = get_server_info(servertype,&servers);
  3469. +  }
  3470. +
  3471. +  if (!domain[0] && !domain_request) {
  3472. +    extern fstring remote_machine;
  3473. +    /* must be a server request with an assumed domain. find a domain */
  3474. +    
  3475. +    if (find_server(servers, total, domain, remote_machine)) {
  3476. +      DEBUG(4, ("No domain specified: using %s for %s\n",
  3477. +        domain, remote_machine));
  3478. +    } else {
  3479. +      /* default to soemthing sensible */
  3480. +      strcpy(domain,my_workgroup());
  3481. +    }
  3482. +  }
  3483.  
  3484.    data_len = fixed_len = string_len = 0;
  3485.  
  3486. -  for (i=0;i<total;i++) {
  3487. -    data_len += fill_server_info(&servers[i],uLevel,0,&f_len,0,&s_len,0);
  3488. -    if (data_len <= buf_len) {
  3489. -      counted++;
  3490. -      fixed_len += f_len;
  3491. -      string_len += s_len;
  3492. +  for (i=0;i<total;i++)
  3493. +    if (filter_server_info(&servers[i],domain)) {
  3494. +      data_len += fill_srv_info(&servers[i],uLevel,0,&f_len,0,&s_len,0);
  3495. +      if (data_len <= buf_len)
  3496. +    {
  3497. +      counted++;
  3498. +      fixed_len += f_len;
  3499. +      string_len += s_len;
  3500. +    }
  3501.      }
  3502. -  }
  3503.  
  3504.    *rdata_len = fixed_len + string_len;
  3505.    *rdata = REALLOC(*rdata,*rdata_len);
  3506.    bzero(*rdata,*rdata_len);
  3507.    
  3508. -  p2 = (*rdata) + fixed_len;    /* auxillery data (strings) will go here */
  3509. +  p2 = (*rdata) + fixed_len;    /* auxilliary data (strings) will go here */
  3510.    p = *rdata;
  3511.    f_len = fixed_len;
  3512.    s_len = string_len;
  3513. -  for (i = 0; i < counted;i++)
  3514. -    fill_server_info(&servers[i],uLevel,&p,&f_len,&p2,&s_len,*rdata);
  3515. +
  3516. +  {
  3517. +    int count2 = counted;
  3518. +    for (i = 0; i < total && count2;i++) {
  3519. +      if (filter_server_info(&servers[i],domain)) {
  3520. +    fill_srv_info(&servers[i],uLevel,&p,&f_len,&p2,&s_len,*rdata);
  3521. +    count2--;
  3522. +      }
  3523. +    }
  3524. +  }
  3525.    
  3526.    *rparam_len = 8;
  3527.    *rparam = REALLOC(*rparam,*rparam_len);
  3528. @@ -943,13 +1038,13 @@
  3529.  
  3530.    if (servers) free(servers);
  3531.  
  3532. -  DEBUG(4,("NetServerEnum uLevel=%d counted=%d total=%d\n",uLevel,counted,total));
  3533. +  DEBUG(3,("NetServerEnum domain = %s uLevel=%d counted=%d total=%d\n",
  3534. +       domain,uLevel,counted,total));
  3535.  
  3536.    return(True);
  3537.  }
  3538.  
  3539.  
  3540. -
  3541.  /****************************************************************************
  3542.    get info about a share
  3543.    ****************************************************************************/
  3544. @@ -1125,7 +1220,7 @@
  3545.    
  3546.    data_len = fixed_len = string_len = 0;
  3547.    for (i=0;i<count;i++)
  3548. -    if (lp_browseable(i))
  3549. +    if (lp_browseable(i) && lp_snum_ok(i))
  3550.        {
  3551.        total++;
  3552.       data_len += fill_share_info(cnum,i,uLevel,0,&f_len,0,&s_len,0);
  3553. @@ -1145,7 +1240,7 @@
  3554.    f_len = fixed_len;
  3555.    s_len = string_len;
  3556.    for (i = 0; i < count;i++)
  3557. -    if (lp_browseable(i))
  3558. +    if (lp_browseable(i) && lp_snum_ok(i))
  3559.        if (fill_share_info(cnum,i,uLevel,&p,&f_len,&p2,&s_len,*rdata) < 0)
  3560.       break;
  3561.    
  3562. @@ -1555,7 +1650,7 @@
  3563.    p += 16;
  3564.    if (uLevel > 0)
  3565.      {
  3566. -      struct server_info_struct *servers=NULL;
  3567. +      struct srv_info_struct *servers=NULL;
  3568.        int i,count;
  3569.        pstring comment;
  3570.        uint32 servertype=SV_TYPE_SERVER_UNIX|SV_TYPE_WORKSTATION|
  3571. @@ -1721,44 +1816,56 @@
  3572.      SCVAL(p,21,0);
  3573.      *p2 = 0;
  3574.      if (uLevel >= 10) {
  3575. -      SIVAL(p,22,PTR_DIFF(p2,*rdata)); /* comment */
  3576. -      SIVAL(p,26,PTR_DIFF(p2,*rdata)); /* user_comment */
  3577. -      SIVAL(p,30,PTR_DIFF(p2,*rdata)); /* full name */
  3578. -      p2++;
  3579. +      SIVAL(p,22,PTR_DIFF(p2,p)); /* comment */
  3580. +      strcpy(p2,"<Comment>");
  3581. +      p2 = skip_string(p2,1);
  3582. +      SIVAL(p,26,PTR_DIFF(p2,p)); /* user_comment */
  3583. +      strcpy(p2,"<UserComment>");
  3584. +      p2 = skip_string(p2,1);
  3585. +      SIVAL(p,30,PTR_DIFF(p2,p)); /* full name */
  3586. +      strcpy(p2,"<FullName>");
  3587. +      p2 = skip_string(p2,1);
  3588.      }
  3589. -    if (uLevel == 11) {
  3590. -      SSVAL(p,34,USER_PRIV_ADMIN); /* user privilege */
  3591. +    if (uLevel == 11) {         /* modelled after NTAS 3.51 reply */
  3592. +      SSVAL(p,34,USER_PRIV_USER); /* user privilege */
  3593.        SIVAL(p,36,0);        /* auth flags */
  3594. -      SIVAL(p,40,0);        /* password age */
  3595. -      SIVAL(p,44,PTR_DIFF(p2,*rdata)); /* home dir */
  3596. -      strcpy(p2,"Y:\\GIGA\\C$\\PRJ\\USERS\\AD");
  3597. +      SIVALS(p,40,-1);        /* password age */
  3598. +      SIVAL(p,44,PTR_DIFF(p2,p)); /* home dir */
  3599. +      strcpy(p2,"\\\\%L\\HOMES");
  3600. +      standard_sub_basic(p2);
  3601.        p2 = skip_string(p2,1);
  3602. -      SIVAL(p,48,PTR_DIFF(p2,*rdata)); /* parms */
  3603. +      SIVAL(p,48,PTR_DIFF(p2,p)); /* parms */
  3604.        strcpy(p2,"");
  3605.        p2 = skip_string(p2,1);
  3606.        SIVAL(p,52,0);        /* last logon */
  3607.        SIVAL(p,56,0);        /* last logoff */
  3608.        SSVALS(p,60,-1);        /* bad pw counts */
  3609.        SSVALS(p,62,-1);        /* num logons */
  3610. -      SIVAL(p,64,PTR_DIFF(p2,*rdata)); /* logon server */
  3611. -      strcpy(p2,"\\\\GIGA");
  3612. +      SIVAL(p,64,PTR_DIFF(p2,p)); /* logon server */
  3613. +      strcpy(p2,"\\\\*");
  3614. +      p2 = skip_string(p2,1);
  3615. +      SSVAL(p,68,0);        /* country code */
  3616. +
  3617. +      SIVAL(p,70,PTR_DIFF(p2,p)); /* workstations */
  3618. +      strcpy(p2,"");
  3619.        p2 = skip_string(p2,1);
  3620. -      SSVAL(p,68,49);        /* country code */
  3621. -      SIVAL(p,70,0);        /* workstations */
  3622.  
  3623.        SIVALS(p,74,-1);        /* max storage */
  3624.        SSVAL(p,78,168);        /* units per week */
  3625. -      SIVAL(p,80,PTR_DIFF(p2,*rdata)); /* logon hours */
  3626. +      SIVAL(p,80,PTR_DIFF(p2,p)); /* logon hours */
  3627.        memset(p2,-1,21);
  3628. -      p2 += 21;
  3629. -      SSVAL(p,84,860);        /* code page */
  3630. +      SCVAL(p2,21,0);           /* fix zero termination */
  3631. +      p2 = skip_string(p2,1);
  3632. +
  3633. +      SSVAL(p,84,0);        /* code page */
  3634.      }
  3635.      if (uLevel == 1 || uLevel == 2) {
  3636.        memset(p+22,' ',16);    /* password */
  3637.        SIVALS(p,38,-1);        /* password age */
  3638.        SSVAL(p,42,USER_PRIV_ADMIN); /* user privilege */
  3639.        SIVAL(p,44,PTR_DIFF(p2,*rdata)); /* home dir */
  3640. -      strcpy(p2,"\\\\__SAMBA__\\HOMES");
  3641. +      strcpy(p2,"\\\\%L\\HOMES");
  3642. +      standard_sub_basic(p2);
  3643.        p2 = skip_string(p2,1);
  3644.        SIVAL(p,48,PTR_DIFF(p2,*rdata)); /* comment */
  3645.        *p2++ = 0;
  3646. @@ -1785,7 +1892,8 @@
  3647.      SSVALS(p,102,-1);    /* bad_pw_count */
  3648.      SSVALS(p,104,-1);    /* num_logons */
  3649.      SIVAL(p,106,PTR_DIFF(p2,*rdata)); /* logon_server */
  3650. -    strcpy(p2,"\\\\__SAMBA__");
  3651. +    strcpy(p2,"\\\\%L");
  3652. +    standard_sub_basic(p2);
  3653.      p2 = skip_string(p2,1);
  3654.      SSVAL(p,110,49);    /* country_code */
  3655.      SSVAL(p,112,860);    /* code page */
  3656. @@ -1878,12 +1986,15 @@
  3657.    desc.buflen = mdrcnt;
  3658.    desc.subformat = NULL;
  3659.    desc.format = str2;
  3660. +  
  3661. +  
  3662.  
  3663.    if (init_package(&desc,1,0)) {
  3664.      PACKI(&desc,"W",0);        /* code */
  3665.      PACKS(&desc,"B21",name);    /* eff. name */
  3666.      PACKS(&desc,"B","");        /* pad */
  3667. -    PACKI(&desc,"W",2);        /* priv */
  3668. +    PACKI(&desc,"W",
  3669. +      Connections[cnum].admin_user?USER_PRIV_ADMIN:USER_PRIV_USER);
  3670.      PACKI(&desc,"D",0);        /* auth flags XXX */
  3671.      PACKI(&desc,"W",0);        /* num logons */
  3672.      PACKI(&desc,"W",0);        /* bad pw count */
  3673. @@ -2218,7 +2329,7 @@
  3674.  
  3675.    queuecnt = 0;
  3676.    for (i = 0; i < services; i++)
  3677. -    if (lp_print_ok(i) && lp_browseable(i))
  3678. +    if (lp_snum_ok(i) && lp_print_ok(i) && lp_browseable(i))
  3679.        queuecnt++;
  3680.  
  3681.    if (mdrcnt > 0) *rdata = REALLOC(*rdata,mdrcnt);
  3682. @@ -2228,7 +2339,7 @@
  3683.      succnt = 0;
  3684.      n = 0;
  3685.      for (i = 0; i < services; i++) {
  3686. -      if (lp_print_ok(i) && lp_browseable(i)) {
  3687. +      if (lp_snum_ok(i) && lp_print_ok(i) && lp_browseable(i)) {
  3688.      fill_printdest_info(cnum,i,uLevel,&desc);
  3689.      n++;
  3690.      if (desc.errcode == NERR_Success) succnt = n;
  3691. diff -u -r --new-file last-version/source/loadparm.c samba-1.9.16alpha1/source/loadparm.c
  3692. --- last-version/source/loadparm.c    Mon Jan 15 19:11:08 1996
  3693. +++ samba-1.9.16alpha1/source/loadparm.c    Sat Feb 10 11:00:47 1996
  3694. @@ -605,6 +605,10 @@
  3695.        string_initial(&sDefault.szLpqcommand,"lpstat -o%p");
  3696.        string_initial(&sDefault.szLprmcommand,"cancel %p-%j");
  3697.        string_initial(&sDefault.szPrintcommand,"lp -c -d%p %s; rm %s");
  3698. +#ifdef SVR4
  3699. +      string_initial(&sDefault.szLppausecommand,"lp -i %p-%j -H hold");
  3700. +      string_initial(&sDefault.szLpresumecommand,"lp -i %p-%j -H resume");
  3701. +#endif
  3702.        break;
  3703.  
  3704.      case PRINT_QNX:
  3705. diff -u -r --new-file last-version/source/local.h samba-1.9.16alpha1/source/local.h
  3706. --- last-version/source/local.h    Tue Jan 16 20:26:37 1996
  3707. +++ samba-1.9.16alpha1/source/local.h    Fri Jan 19 20:01:17 1996
  3708. @@ -133,7 +133,7 @@
  3709.  #define SMBD_RELOAD_CHECK (10)
  3710.  #define SHARE_MODES_CHECK (10)
  3711.  #define SHARE_MODES_CLEAN (300)
  3712. -#define IDLE_CLOSED_TIMEOUT (30)
  3713. +#define IDLE_CLOSED_TIMEOUT (60)
  3714.  #define DPTR_IDLE_TIMEOUT (120)
  3715.  #define SMBD_SELECT_LOOP (10)
  3716.  #define NMBD_SELECT_LOOP (10)
  3717. diff -u -r --new-file last-version/source/nameserv.c samba-1.9.16alpha1/source/nameserv.c
  3718. --- last-version/source/nameserv.c    Mon Jan 15 18:38:56 1996
  3719. +++ samba-1.9.16alpha1/source/nameserv.c    Thu Feb 29 00:12:08 1996
  3720. @@ -186,11 +186,11 @@
  3721.  ****************************************************************************/
  3722.  static void fault_continue(void)
  3723.  {
  3724. -  static int errcount=0;
  3725. +  static int errcount=1;
  3726.  
  3727. -  errcount++;
  3728. +  errcount--;
  3729.  
  3730. -  if (is_daemon && errcount<100)
  3731. +  if (is_daemon && errcount)
  3732.      process();
  3733.  
  3734.  #if DUMP_CORE
  3735. @@ -200,6 +200,21 @@
  3736.    return;
  3737.  }
  3738.  
  3739. +
  3740. +/*******************************************************************
  3741. +  wrapper to get the DC
  3742. +  ******************************************************************/
  3743. +static char *domain_controller(void)
  3744. +{
  3745. +  char *dc = lp_domain_controller();
  3746. +  /* so many people mistake this for a bool that we need to handle it. sigh. */
  3747. +  if (!*dc || strequal(dc,"yes") || strequal(dc,"true"))
  3748. +    strcpy(dc,myname);
  3749. +  return(dc);
  3750. +}
  3751. +
  3752. +
  3753. +
  3754.  /****************************************************************************
  3755.    true if two netbios names are equal
  3756.  ****************************************************************************/
  3757. @@ -515,8 +530,8 @@
  3758.    
  3759.    
  3760.    fclose(f);
  3761. -  unlink(fname);
  3762.    chmod(fnamenew,0644);
  3763. +  /* unlink(fname); */
  3764.    rename(fnamenew,fname);   
  3765.    DEBUG(3,("Wrote browse list %s\n",fname));
  3766.  }
  3767. @@ -1000,16 +1015,18 @@
  3768.    fstring pdcname;
  3769.    *pdcname = 0;
  3770.  
  3771. +  if (strequal(domain_controller(),myname)) return;
  3772. +
  3773.    if (!AM_MASTER || (last && (t-last < 10*60))) return;
  3774.    last = t;
  3775.  
  3776. -  ip = *interpret_addr2(lp_domain_controller());
  3777. +  ip = *interpret_addr2(domain_controller());
  3778.  
  3779.    if (zero_ip(ip)) ip = bcast_ip;
  3780.  
  3781.    if (!name_query(ClientNMB,PrimaryGroup,
  3782.            0x1b,False,False,ip,&pdc_ip,queue_packet)) {
  3783. -    DEBUG(2,("Failed to find PDC at %s\n",lp_domain_controller()));
  3784. +    DEBUG(2,("Failed to find PDC at %s\n",domain_controller()));
  3785.      return;
  3786.    }
  3787.  
  3788. @@ -1036,7 +1053,7 @@
  3789.    p = skip_string(p,1);
  3790.  
  3791.    send_mailslot_reply(BROWSE_MAILSLOT,ClientDGRAM,outbuf,PTR_DIFF(p,outbuf),
  3792. -              PrimaryGroup,myname,0x1b,0,pdc_ip,myip);
  3793. +              myname,PrimaryGroup,0x1b,0,pdc_ip,myip);
  3794.  }
  3795.  
  3796.  
  3797. @@ -1289,11 +1306,9 @@
  3798.  static void process_logon_packet(struct packet_struct *p,char *buf,int len)
  3799.  {
  3800.    char *logname,*q;
  3801. -  char *reply_name;
  3802. -  BOOL add_slashes = False;
  3803.    pstring outbuf;
  3804.    struct dgram_packet *dgram = &p->packet.dgram;
  3805. -  int code,reply_code;
  3806. +  int code;
  3807.  
  3808.    if (!lp_domain_logons()) {
  3809.      DEBUG(3,("No domain logons\n"));
  3810. @@ -1304,6 +1319,9 @@
  3811.      return;
  3812.    }
  3813.  
  3814. +  q = outbuf;
  3815. +  bzero(outbuf,sizeof(outbuf));
  3816. +
  3817.    code = SVAL(buf,0);
  3818.    switch (code) {
  3819.    case 0:    
  3820. @@ -1311,9 +1329,17 @@
  3821.        char *machine = buf+2;
  3822.        char *user = skip_string(machine,1);
  3823.        logname = skip_string(user,1);
  3824. -      reply_code = 6;
  3825. -      reply_name = myname;
  3826. -      add_slashes = True;
  3827. +
  3828. +      SSVAL(q,0,6);
  3829. +      q += 2;
  3830. +      strcpy(q,"\\\\");
  3831. +      q += 2;
  3832. +      StrnCpy(q,myname,16);
  3833. +      strupper(q);
  3834. +      q = skip_string(q,1);
  3835. +      SSVAL(q,0,0xFFFF);
  3836. +      q += 2;
  3837. +
  3838.        DEBUG(3,("Domain login request from %s(%s) user=%s\n",
  3839.             machine,inet_ntoa(p->ip),user));
  3840.      }
  3841. @@ -1322,12 +1348,17 @@
  3842.      {
  3843.        char *machine = buf+2;
  3844.        logname = skip_string(machine,1);
  3845. -      reply_code = 7;
  3846. -      reply_name = lp_domain_controller();
  3847. -      if (!*reply_name) {
  3848. -    DEBUG(3,("No domain controller configured\n"));
  3849. -    return;
  3850. -      }
  3851. +
  3852. +      SSVAL(q,0,0xc);
  3853. +      q += 2;
  3854. +      StrnCpy(q,domain_controller(),16);
  3855. +      strupper(q);
  3856. +      q = skip_string(q,1);
  3857. +      q += PutUniCode(q,domain_controller());
  3858. +      q += PutUniCode(q,dgram->dest_name.name);
  3859. +      SSVAL(q,0,0xFFFF);
  3860. +      q += 2;
  3861. +
  3862.        DEBUG(3,("GETDC request from %s(%s)\n",
  3863.             machine,inet_ntoa(p->ip)));
  3864.      }
  3865. @@ -1337,19 +1368,6 @@
  3866.      return;
  3867.    }
  3868.  
  3869. -  bzero(outbuf,sizeof(outbuf));
  3870. -  q = outbuf;
  3871. -  SSVAL(q,0,reply_code);
  3872. -  q += 2;
  3873. -  if (add_slashes) {
  3874. -    strcpy(q,"\\\\");
  3875. -    q += 2;
  3876. -  }
  3877. -  StrnCpy(q,reply_name,16);
  3878. -  strupper(q);
  3879. -  q = skip_string(q,1);
  3880. -  SSVAL(q,0,0xFFFF);
  3881. -  q += 2;
  3882.  
  3883.    send_mailslot_reply(logname,ClientDGRAM,outbuf,PTR_DIFF(q,outbuf),
  3884.                myname,&dgram->source_name.name[0],0,0,p->ip,myip);  
  3885. @@ -1446,7 +1464,7 @@
  3886.    }
  3887.  
  3888.    /* if I have a domain controller then announce to it */
  3889. -  if (AM_MASTER && *lp_domain_controller())
  3890. +  if (AM_MASTER)
  3891.      announce_master(PrimaryGroup);
  3892.  
  3893.    needannounce=False;
  3894. @@ -2112,6 +2130,12 @@
  3895.      strcpy(myname,myhostname);
  3896.      p = strchr(myname,'.');
  3897.      if (p) *p = 0;
  3898. +  }
  3899. +
  3900. +  {
  3901. +    extern fstring local_machine;
  3902. +    strcpy(local_machine,myname);
  3903. +    strupper(local_machine);
  3904.    }
  3905.  
  3906.    return True;
  3907. diff -u -r --new-file last-version/source/nmbsync.c samba-1.9.16alpha1/source/nmbsync.c
  3908. --- last-version/source/nmbsync.c    Wed Nov 22 18:16:20 1995
  3909. +++ samba-1.9.16alpha1/source/nmbsync.c    Sun Feb 18 18:12:18 1996
  3910. @@ -186,7 +186,8 @@
  3911.    uid = SVAL(inbuf,smb_uid);
  3912.  
  3913.    bzero(outbuf,smb_size);
  3914. -  set_message(outbuf,4,2 + strlen(service) + 1 + strlen(dev),True);
  3915. +  set_message(outbuf,4,2 + (2 + strlen(name) + 1 + strlen(service)) +
  3916. +       1 + strlen(dev),True);
  3917.    CVAL(outbuf,smb_com) = SMBtconX;
  3918.    SSVAL(outbuf,smb_uid,uid);
  3919.  
  3920. @@ -194,7 +195,10 @@
  3921.    SSVAL(outbuf,smb_vwv3,1);
  3922.  
  3923.    p = smb_buf(outbuf) + 1;
  3924. -  strcpy(p,service);
  3925. +  strcpy(p, "\\\\");
  3926. +  strcat(p, name);
  3927. +  strcat(p, "\\");
  3928. +  strcat(p,service);
  3929.    p = skip_string(p,1);
  3930.    strcpy(p,dev);
  3931.  
  3932. diff -u -r --new-file last-version/source/password.c samba-1.9.16alpha1/source/password.c
  3933. --- last-version/source/password.c    Mon Jan 15 13:04:50 1996
  3934. +++ samba-1.9.16alpha1/source/password.c    Tue Jan 30 17:26:05 1996
  3935. @@ -737,6 +737,14 @@
  3936.    }
  3937.  #endif
  3938.  
  3939. +#ifdef HPUX_10_TRUSTED
  3940. +  {
  3941. +    struct pr_passwd *pr_pw = getprpwnam(pass->pw_name);
  3942. +    if (pr_pw && pr_pw->ufld.fd_encrypt)
  3943. +      pass->pw_passwd = pr_pw->ufld.fd_encrypt;
  3944. +  }
  3945. +#endif
  3946. +
  3947.  #ifdef OSF1_ENH_SEC
  3948.    {
  3949.      struct pr_passwd *mypasswd;
  3950. diff -u -r --new-file last-version/source/printing.c samba-1.9.16alpha1/source/printing.c
  3951. --- last-version/source/printing.c    Mon Jan 15 12:29:51 1996
  3952. +++ samba-1.9.16alpha1/source/printing.c    Wed Jan 31 21:18:37 1996
  3953. @@ -488,18 +488,19 @@
  3954.  here is an example of "lpstat -o dcslw" output under sysv
  3955.  
  3956.  dcslw-896               tridge            4712   Dec 20 10:30:30 on dcslw
  3957. +dcslw-897               tridge            4712   Dec 20 10:30:30 being held
  3958.  
  3959.  ****************************************************************************/
  3960.  static BOOL parse_lpq_sysv(char *line,print_queue_struct *buf,BOOL first)
  3961.  {
  3962. -  string tok[8];
  3963. +  string tok[9];
  3964.    int count=0;
  3965.    char *p;
  3966.  
  3967.    /* handle the dash in the job id */
  3968.    string_sub(line,"-"," ");
  3969.    
  3970. -  for (count=0; count<8 && next_token(&line,tok[count],NULL); count++) ;
  3971. +  for (count=0; count<9 && next_token(&line,tok[count],NULL); count++) ;
  3972.  
  3973.    /* we must get 7 tokens */
  3974.    if (count < 7)
  3975. @@ -520,7 +521,12 @@
  3976.  
  3977.    buf->job = atoi(tok[1]);
  3978.    buf->size = atoi(tok[3]);
  3979. -  buf->status = strequal(tok[7],"on")?LPQ_PRINTING:LPQ_QUEUED;
  3980. +  if (count > 7 && strequal(tok[7],"on"))
  3981. +    buf->status = LPQ_PRINTING;
  3982. +  else if (count > 8 && strequal(tok[7],"being") && strequal(tok[8],"held"))
  3983. +    buf->status = LPQ_PAUSED;
  3984. +  else
  3985. +    buf->status = LPQ_QUEUED;
  3986.    buf->priority = 0;
  3987.    buf->time = EntryTime(tok, 4, count, 7);
  3988.    StrnCpy(buf->user,tok[2],sizeof(buf->user)-1);
  3989. diff -u -r --new-file last-version/source/reply.c samba-1.9.16alpha1/source/reply.c
  3990. --- last-version/source/reply.c    Tue Jan 16 20:28:29 1996
  3991. +++ samba-1.9.16alpha1/source/reply.c    Thu Feb 29 00:19:48 1996
  3992. @@ -334,6 +334,11 @@
  3993.      StrnCpy(smb_apasswd,p + passlen1,smb_apasslen);
  3994.        }
  3995.      }
  3996. +    if (passlen2 == 1) {
  3997. +      /* apparently NT sometimes sets passlen2 to 1 when it means 0. This
  3998. +     tries to work around that problem */
  3999. +      passlen2 = 0;
  4000. +    }
  4001.      p += passlen1 + passlen2;
  4002.      strcpy(user,p); p = skip_string(p,1);
  4003.      DEBUG(3,("Domain=[%s]  NativeOS=[%s] NativeLanMan=[%s]\n",
  4004. @@ -578,7 +583,7 @@
  4005.    if (directory_exist(fname,NULL))
  4006.      mode |= aDIR;
  4007.    if (check_name(fname,cnum))
  4008. -    ok =  (dos_chmod(cnum,fname,mode) == 0);
  4009. +    ok =  (dos_chmod(cnum,fname,mode,NULL) == 0);
  4010.    if (ok)
  4011.      ok = set_filetime(fname,mtime);
  4012.    
  4013. @@ -992,7 +997,7 @@
  4014.    if (!check_name(fname,cnum))
  4015.      return(UNIXERROR(ERRDOS,ERRnoaccess));
  4016.  
  4017. -  unixmode = unix_mode(cnum,smb_attr);
  4018. +  unixmode = unix_mode(cnum,smb_attr | aARCH);
  4019.        
  4020.    open_file_shared(fnum,cnum,fname,smb_mode,smb_ofun,unixmode,
  4021.             &rmode,&smb_action);
  4022. @@ -1564,7 +1569,7 @@
  4023.      DEBUG(0,("couldn't seek to %d in writebraw\n",startpos));
  4024.  
  4025.    if (numtowrite>0)
  4026. -    nwritten = write_data(Files[fnum].fd,data,numtowrite);
  4027. +    nwritten = write_file(fnum,data,numtowrite);
  4028.    
  4029.    DEBUG(3,("%s writebraw1 fnum=%d cnum=%d start=%d num=%d wrote=%d sync=%d\n",
  4030.         timestring(),fnum,cnum,startpos,numtowrite,nwritten,write_through));
  4031. @@ -1632,7 +1637,6 @@
  4032.    int cnum,fnum;
  4033.    int nwritten = -1;
  4034.    int outsize = 0;
  4035. -  int fd;
  4036.    char *data;
  4037.    uint32 numtowrite,startpos;
  4038.    int eclass;
  4039. @@ -1649,8 +1653,6 @@
  4040.    startpos = IVAL(inbuf,smb_vwv2);
  4041.    data = smb_buf(inbuf) + 3;
  4042.    
  4043. -  fd = Files[fnum].fd;
  4044. -
  4045.    if (is_locked(fnum,cnum,numtowrite,startpos))
  4046.      return(ERROR(ERRDOS,ERRlock));
  4047.  
  4048. @@ -1662,7 +1664,7 @@
  4049.    if(numtowrite == 0)
  4050.      nwritten = 0;
  4051.    else
  4052. -    nwritten = write_data(fd,data,numtowrite);
  4053. +    nwritten = write_file(fnum,data,numtowrite);
  4054.    
  4055.    if (lp_syncalways(SNUM(cnum)))
  4056.      sync_file(fnum);
  4057. @@ -1693,7 +1695,6 @@
  4058.    int nwritten = -1;
  4059.    int outsize = 0;
  4060.    int startpos;
  4061. -  int fd;
  4062.    char *data;
  4063.  
  4064.    dum1 = dum2 = 0;
  4065. @@ -1710,8 +1711,6 @@
  4066.    startpos = IVAL(inbuf,smb_vwv2);
  4067.    data = smb_buf(inbuf) + 3;
  4068.    
  4069. -  fd = Files[fnum].fd;
  4070. -
  4071.    if (is_locked(fnum,cnum,numtowrite,startpos))
  4072.      return(ERROR(ERRDOS,ERRlock));
  4073.  
  4074. @@ -1721,9 +1720,9 @@
  4075.       zero then the file size should be extended or
  4076.       truncated to the size given in smb_vwv[2-3] */
  4077.    if(numtowrite == 0)
  4078. -    nwritten = set_filelen(fd, startpos);
  4079. +    nwritten = set_filelen(Files[fnum].fd, startpos);
  4080.    else
  4081. -    nwritten = write_data(fd,data,numtowrite);
  4082. +    nwritten = write_file(fnum,data,numtowrite);
  4083.    
  4084.    if (lp_syncalways(SNUM(cnum)))
  4085.      sync_file(fnum);
  4086. @@ -1761,7 +1760,6 @@
  4087.    int cnum;
  4088.    int nwritten = -1;
  4089.    int outsize = 0;
  4090. -  int fd;
  4091.    char *data;
  4092.  
  4093.    cnum = SVAL(inbuf,smb_tid);
  4094. @@ -1772,8 +1770,6 @@
  4095.  
  4096.    data = smb_base(inbuf) + smb_doff;
  4097.  
  4098. -  fd = Files[fnum].fd;
  4099. -
  4100.    if (is_locked(fnum,cnum,smb_dsize,smb_offs))
  4101.      return(ERROR(ERRDOS,ERRlock));
  4102.  
  4103. @@ -1786,7 +1782,7 @@
  4104.    if(smb_dsize == 0)
  4105.      nwritten = 0;
  4106.    else
  4107. -    nwritten = write_data(fd,data,smb_dsize);
  4108. +    nwritten = write_file(fnum,data,smb_dsize);
  4109.    
  4110.    if(((nwritten == 0) && (smb_dsize != 0))||(nwritten < 0))
  4111.      return(UNIXERROR(ERRDOS,ERRnoaccess));
  4112. @@ -1974,7 +1970,7 @@
  4113.        
  4114.    seek_file(fnum,startpos);
  4115.        
  4116. -  nwritten = write_data(Files[fnum].fd,data,numtowrite);
  4117. +  nwritten = write_file(fnum,data,numtowrite);
  4118.  
  4119.    close_file(fnum);
  4120.  
  4121. @@ -2321,7 +2317,7 @@
  4122.    numtowrite = SVAL(smb_buf(inbuf),1);
  4123.    data = smb_buf(inbuf) + 3;
  4124.    
  4125. -  if (write_data(Files[fnum].fd,data,numtowrite) != numtowrite)
  4126. +  if (write_file(fnum,data,numtowrite) != numtowrite)
  4127.      return(UNIXERROR(ERRDOS,ERRnoaccess));
  4128.    
  4129.    DEBUG(3,("%s printwrite fnum=%d cnum=%d num=%d\n",timestring(),fnum,cnum,numtowrite));
  4130. @@ -2585,7 +2581,7 @@
  4131.  {
  4132.    int Access,action;
  4133.    struct stat st;
  4134. -  int ret;
  4135. +  int ret=0;
  4136.    int fnum1,fnum2;
  4137.    pstring dest;
  4138.    
  4139. @@ -2964,7 +2960,6 @@
  4140.    int outsize = 0;
  4141.    int32 startpos;
  4142.    int tcount, write_through, smb_doff;
  4143. -  int fd;
  4144.    char *data;
  4145.    
  4146.    cnum = SVAL(inbuf,smb_tid);
  4147. @@ -2986,13 +2981,11 @@
  4148.       not an SMBwritebmpx - set this up now so we don't forget */
  4149.    CVAL(outbuf,smb_com) = SMBwritec;
  4150.  
  4151. -  fd = Files[fnum].fd;
  4152. -
  4153.    if (is_locked(fnum,cnum,tcount,startpos))
  4154.      return(ERROR(ERRDOS,ERRlock));
  4155.  
  4156.    seek_file(fnum,startpos);
  4157. -  nwritten = write_data(fd,data,numtowrite);
  4158. +  nwritten = write_file(fnum,data,numtowrite);
  4159.  
  4160.    if(lp_syncalways(SNUM(cnum)) || write_through)
  4161.      sync_file(fnum);
  4162. @@ -3060,7 +3053,6 @@
  4163.    int outsize = 0;
  4164.    int32 startpos;
  4165.    int tcount, write_through, smb_doff;
  4166. -  int fd;
  4167.    char *data;
  4168.    write_bmpx_struct *wbms;
  4169.    BOOL send_response = False;
  4170. @@ -3093,10 +3085,8 @@
  4171.    if(wbms->wr_discard)
  4172.      return -1; /* Just discard the packet */
  4173.  
  4174. -  fd = Files[fnum].fd;
  4175. -
  4176.    seek_file(fnum,startpos);
  4177. -  nwritten = write_data(fd,data,numtowrite);
  4178. +  nwritten = write_file(fnum,data,numtowrite);
  4179.  
  4180.    if(lp_syncalways(SNUM(cnum)) || write_through)
  4181.      sync_file(fnum);
  4182. @@ -3186,7 +3176,7 @@
  4183.    CHECK_ERROR(fnum);
  4184.  
  4185.    /* Do an fstat on this file */
  4186. -  if(fstat( Files[fnum].fd, &sbuf))
  4187. +  if(fstat(Files[fnum].fd, &sbuf))
  4188.      return(UNIXERROR(ERRDOS,ERRnoaccess));
  4189.    
  4190.    mode = dos_mode(cnum,Files[fnum].name,&sbuf);
  4191. diff -u -r --new-file last-version/source/server.c samba-1.9.16alpha1/source/server.c
  4192. --- last-version/source/server.c    Mon Jan 15 13:08:53 1996
  4193. +++ samba-1.9.16alpha1/source/server.c    Thu Feb 29 00:12:08 1996
  4194. @@ -211,18 +211,21 @@
  4195.  /*******************************************************************
  4196.  chmod a file - but preserve some bits
  4197.  ********************************************************************/
  4198. -int dos_chmod(int cnum,char *fname,int dosmode)
  4199. +int dos_chmod(int cnum,char *fname,int dosmode,struct stat *st)
  4200.  {
  4201. -  struct stat st;
  4202. +  struct stat st1;
  4203.    int mask=0;
  4204.    int tmp;
  4205.    int unixmode;
  4206.  
  4207. -  if (sys_stat(fname,&st)) return(-1);
  4208. +  if (!st) {
  4209. +    st = &st1;
  4210. +    if (sys_stat(fname,st)) return(-1);
  4211. +  }
  4212.  
  4213. -  if (S_ISDIR(st.st_mode)) dosmode |= aDIR;
  4214. +  if (S_ISDIR(st->st_mode)) dosmode |= aDIR;
  4215.  
  4216. -  if (dos_mode(cnum,fname,&st) == dosmode) return(0);
  4217. +  if (dos_mode(cnum,fname,st) == dosmode) return(0);
  4218.  
  4219.    unixmode = unix_mode(cnum,dosmode);
  4220.  
  4221. @@ -239,10 +242,10 @@
  4222.    if (!MAP_SYSTEM(cnum)) mask |= S_IXGRP;
  4223.    if (!MAP_HIDDEN(cnum)) mask |= S_IXOTH;
  4224.  
  4225. -  unixmode |= (st.st_mode & mask);
  4226. +  unixmode |= (st->st_mode & mask);
  4227.  
  4228.    /* if we previously had any r bits set then leave them alone */
  4229. -  if ((tmp = st.st_mode & (S_IRUSR|S_IRGRP|S_IROTH))) {
  4230. +  if ((tmp = st->st_mode & (S_IRUSR|S_IRGRP|S_IROTH))) {
  4231.      unixmode &= ~(S_IRUSR|S_IRGRP|S_IROTH);
  4232.      unixmode |= tmp;
  4233.    }
  4234. @@ -250,7 +253,7 @@
  4235.    /* if we previously had any w bits set then leave them alone 
  4236.     if the new mode is not rdonly */
  4237.    if (!IS_DOS_READONLY(dosmode) &&
  4238. -      (tmp = st.st_mode & (S_IWUSR|S_IWGRP|S_IWOTH))) {
  4239. +      (tmp = st->st_mode & (S_IWUSR|S_IWGRP|S_IWOTH))) {
  4240.      unixmode &= ~(S_IWUSR|S_IWGRP|S_IWOTH);
  4241.      unixmode |= tmp;
  4242.    }
  4243. @@ -522,6 +525,96 @@
  4244.  
  4245.  
  4246.  #ifdef QUOTAS
  4247. +#ifdef LINUX
  4248. +/****************************************************************************
  4249. +try to get the disk space from disk quotas (LINUX version)
  4250. +****************************************************************************/
  4251. +/*
  4252. +If you didn't make the symlink to the quota package, too bad :(
  4253. +*/
  4254. +#include "quota/quotactl.c"
  4255. +#include "quota/hasquota.c"
  4256. +static BOOL disk_quotas(char *path, int *bsize, int *dfree, int *dsize)
  4257. +{
  4258. +  uid_t euser_id;
  4259. +  struct dqblk D;
  4260. +  struct stat S;
  4261. +  dev_t devno ;
  4262. +  struct mntent *mnt;
  4263. +  FILE *fp;
  4264. +  int found ;
  4265. +  int qcmd, fd ;
  4266. +  char *qfpathname;
  4267. +  
  4268. +  /* find the block device file */
  4269. +  
  4270. +  if ( stat(path, &S) == -1 )
  4271. +    return(False) ;
  4272. +
  4273. +  devno = S.st_dev ;
  4274. +  
  4275. +  fp = setmntent(MOUNTED,"r");
  4276. +  found = False ;
  4277. +  
  4278. +  while ((mnt = getmntent(fp)) != (struct mntent *) 0) {
  4279. +    if ( stat(mnt->mnt_dir,&S) == -1 )
  4280. +      continue ;
  4281. +    if (S.st_dev == devno) {
  4282. +      found = True ;
  4283. +      break ;
  4284. +    }
  4285. +  }
  4286. +  endmntent(fp) ;
  4287. +  
  4288. +  if ( ! found )
  4289. +    return(False) ;
  4290. +  
  4291. +  qcmd = QCMD(Q_GETQUOTA, USRQUOTA);
  4292. +  
  4293. +  if (hasmntopt(mnt, MNTOPT_NOAUTO) || hasmntopt(mnt, MNTOPT_NOQUOTA))
  4294. +    return(False) ;
  4295. +  
  4296. +  if (!hasquota(mnt, USRQUOTA, &qfpathname))
  4297. +    return(False) ;
  4298. +  
  4299. +  euser_id = geteuid();
  4300. +  seteuid(0);
  4301. +  
  4302. +  if (quotactl(qcmd, mnt->mnt_fsname, euser_id, (caddr_t)&D) != 0) {
  4303. +    if ((fd = open(qfpathname, O_RDONLY)) < 0) {
  4304. +      seteuid(euser_id);
  4305. +      return(False);
  4306. +    }
  4307. +    lseek(fd, (long) dqoff(euser_id), L_SET);
  4308. +    switch (read(fd, &D, sizeof(struct dqblk))) {
  4309. +    case 0:/* EOF */
  4310. +      memset((caddr_t)&D, 0, sizeof(struct dqblk));
  4311. +      break;
  4312. +    case sizeof(struct dqblk):   /* OK */
  4313. +      break;
  4314. +    default:   /* ERROR */
  4315. +      close(fd);
  4316. +      seteuid(euser_id);
  4317. +      return(False);
  4318. +    }
  4319. +  }
  4320. +  seteuid(euser_id);
  4321. +  *bsize=1024;
  4322. +
  4323. +  if (D.dqb_bsoftlimit==0)
  4324. +    return(False);
  4325. +  if ((D.dqb_curblocks>D.dqb_bsoftlimit)||(D.dqb_curinodes>D.dqb_isoftlimit))
  4326. +    {
  4327. +      *dfree = 0;
  4328. +      *dsize = D.dqb_curblocks;
  4329. +    }
  4330. +  else {
  4331. +    *dfree = D.dqb_bsoftlimit - D.dqb_curblocks;
  4332. +    *dsize = D.dqb_bsoftlimit;
  4333. +  }
  4334. +  return (True);
  4335. +}
  4336. +#else
  4337.  #ifndef CRAY
  4338.  /****************************************************************************
  4339.  try to get the disk space from disk quotas
  4340. @@ -670,6 +763,7 @@
  4341.    
  4342.  }
  4343.  #endif /* CRAY */
  4344. +#endif /* LINUX */
  4345.  #endif /* QUOTAS */
  4346.  
  4347.  
  4348. @@ -1014,6 +1108,7 @@
  4349.        Files[fnum].share_mode = 0;
  4350.        Files[fnum].share_pending = False;
  4351.        Files[fnum].print_file = Connections[cnum].printer;
  4352. +      Files[fnum].modified = False;
  4353.        Files[fnum].cnum = cnum;
  4354.        string_set(&Files[fnum].name,fname);
  4355.        Files[fnum].wbmpx_ptr = NULL;      
  4356. @@ -1029,7 +1124,7 @@
  4357.        Files[fnum].can_write) 
  4358.      {
  4359.        DEBUG(3,("Writing postscript line\n"));
  4360. -      write_data(Files[fnum].fd,"%!\n",3);
  4361. +      write_file(fnum,"%!\n",3);
  4362.      }
  4363.        
  4364.        DEBUG(2,("%s %s opened file %s read=%s write=%s (numopen=%d fnum=%d)\n",
  4365. @@ -1132,6 +1227,16 @@
  4366.    if (lp_share_modes(SNUM(cnum)))
  4367.      del_share_mode(fnum);
  4368.  
  4369. +  if (Files[fnum].modified) {
  4370. +    struct stat st;
  4371. +    if (fstat(Files[fnum].fd,&st) == 0) {
  4372. +      int dosmode = dos_mode(cnum,Files[fnum].name,&st);
  4373. +      if (!IS_DOS_ARCHIVE(dosmode)) {    
  4374. +    dos_chmod(cnum,Files[fnum].name,dosmode | aARCH,&st);
  4375. +      }
  4376. +    }    
  4377. +  }
  4378. +
  4379.    close(Files[fnum].fd);
  4380.  
  4381.    /* NT uses smbclose to start a print - weird */
  4382. @@ -1151,12 +1256,29 @@
  4383.  /*******************************************************************
  4384.  reproduce the share mode access table
  4385.  ********************************************************************/
  4386. -static int access_table(int new_deny,int old_deny,int old_mode)
  4387. +static int access_table(int new_deny,int old_deny,int old_mode,
  4388. +            int share_pid,char *fname)
  4389.  {
  4390.    if (new_deny == DENY_ALL || old_deny == DENY_ALL) return(AFAIL);
  4391.  
  4392.    if (new_deny == DENY_DOS || old_deny == DENY_DOS) {
  4393. +    if (old_deny == new_deny && share_pid == getpid()) 
  4394. +    return(AALL);    
  4395. +
  4396.      if (old_mode == 0) return(AREAD);
  4397. +
  4398. +    /* the new smbpub.zip spec says that if the file extension is
  4399. +       .com, .dll, .exe or .sym then allow the open. I will force
  4400. +       it to read-only as this seems sensible although the spec is
  4401. +       a little unclear on this. */
  4402. +    if ((fname = strrchr(fname,'.'))) {
  4403. +      if (strequal(fname,".com") ||
  4404. +      strequal(fname,".dll") ||
  4405. +      strequal(fname,".exe") ||
  4406. +      strequal(fname,".sym"))
  4407. +    return(AREAD);
  4408. +    }
  4409. +
  4410.      return(AFAIL);
  4411.    }
  4412.  
  4413. @@ -1312,31 +1434,17 @@
  4414.      return;
  4415.        }
  4416.  
  4417. -      /* C. Hoch 11/21/95 Handle DOS (compatibility) mode on the same machine.
  4418. -       * Any number of read and/or write opens in compatibility mode from the 
  4419. -       * same machine are allowed.
  4420. -       * Also, read opens in compatibility mode from different machines
  4421. -       * are allowed, even if the file is already opened for read in some
  4422. -       * share mode. This is "soft compatibility" mode (Microsoft Knowledge Base,
  4423. -       * WfWG, "How VSHARE386 Manages File Sharing", Q90239), and is handled in
  4424. -       * access_table().
  4425. -       */
  4426. -      if ((deny_mode==DENY_DOS || old_deny_mode==DENY_DOS) && 
  4427. -      share_pid == getpid()) {
  4428. -    if (old_deny_mode != deny_mode) {
  4429. -      DEBUG(2,("Share violation on file %s\n",fname));
  4430. -      errno = EACCES;
  4431. -      unix_ERR_class = ERRDOS;
  4432. -      unix_ERR_code = ERRbadshare;
  4433. -      return;
  4434. -    }
  4435. -      } else {
  4436. -    int access_allowed = access_table(deny_mode,old_deny_mode,old_open_mode);
  4437. +      {
  4438. +    int access_allowed = access_table(deny_mode,old_deny_mode,old_open_mode,
  4439. +                      share_pid,fname);
  4440.  
  4441.      if ((access_allowed == AFAIL) ||
  4442.          (access_allowed == AREAD && flags == O_WRONLY) ||
  4443.          (access_allowed == AWRITE && flags == O_RDONLY)) {
  4444. -      DEBUG(2,("Share violation on file %s\n",fname));
  4445. +      DEBUG(2,("Share violation on file (%d,%d,%d,%d,%s) = %d\n",
  4446. +           deny_mode,old_deny_mode,old_open_mode,
  4447. +           share_pid,fname,
  4448. +           access_allowed));
  4449.        errno = EACCES;
  4450.        unix_ERR_class = ERRDOS;
  4451.        unix_ERR_code = ERRbadshare;
  4452. @@ -1362,7 +1470,7 @@
  4453.    }
  4454.  
  4455.    if (Files[fnum].open) {
  4456. -    int open_mode;
  4457. +    int open_mode=0;
  4458.      switch (flags) {
  4459.      case O_RDONLY:
  4460.        open_mode = 0;
  4461. @@ -1491,6 +1599,22 @@
  4462.  }
  4463.  
  4464.  
  4465. +/****************************************************************************
  4466. +write to a file
  4467. +****************************************************************************/
  4468. +int write_file(int fnum,char *data,int n)
  4469. +{
  4470. +  if (!Files[fnum].can_write) {
  4471. +    errno = EPERM;
  4472. +    return(0);
  4473. +  }
  4474. +
  4475. +  Files[fnum].modified = True;
  4476. +
  4477. +  return(write_data(Files[fnum].fd,data,n));
  4478. +}
  4479. +
  4480. +
  4481.  static int old_umask = 022;
  4482.  
  4483.  /****************************************************************************
  4484. @@ -3354,6 +3478,7 @@
  4485.      char *home = get_home_dir(Connections[cnum].user);
  4486.      if (home) string_sub(s,"%H",home);
  4487.        }
  4488. +      string_sub(s,"%g",gidtoname(Connections[cnum].gid));
  4489.      }
  4490.    standard_sub_basic(s);
  4491.  }
  4492. @@ -3994,13 +4119,12 @@
  4493.    int opt;
  4494.    extern char *optarg;
  4495.  
  4496. -#ifdef SecureWare
  4497. +#ifdef NEED_AUTH_PARAMETERS
  4498.    set_auth_parameters(argc,argv);
  4499. -  setluid(0);
  4500.  #endif
  4501.  
  4502. -#ifdef OSF1_ENH_SEC
  4503. -  set_auth_parameters(argc,argv);
  4504. +#ifdef SecureWare
  4505. +  setluid(0);
  4506.  #endif
  4507.  
  4508.    append_log = True;
  4509. diff -u -r --new-file last-version/source/smb.h samba-1.9.16alpha1/source/smb.h
  4510. --- last-version/source/smb.h    Mon Jan 15 14:14:46 1996
  4511. +++ samba-1.9.16alpha1/source/smb.h    Thu Feb 29 00:12:08 1996
  4512. @@ -259,6 +259,7 @@
  4513.    BOOL share_mode;
  4514.    BOOL share_pending;
  4515.    BOOL print_file;
  4516. +  BOOL modified;
  4517.    char *name;
  4518.  } files_struct;
  4519.  
  4520. @@ -612,13 +613,13 @@
  4521.  int TvalDiff(struct timeval *tvalold,struct timeval *tvalnew);
  4522.  int smb_offset(char *p,char *buf);
  4523.  void sync_file(int fnum);
  4524. -void PutUniCode(char *dst,char *src);
  4525. +int PutUniCode(char *dst,char *src);
  4526.  void map_username(char *user);
  4527.  void close_low_fds(void);
  4528.  void clean_share_files(void);
  4529.  int write_socket(int fd,char *buf,int len);
  4530.  char *readdirname(void *p);
  4531. -int dos_chmod(int cnum,char *fname,int mode);
  4532. +int dos_chmod(int cnum,char *fname,int mode,struct stat *st);
  4533.  int smb_numwords(char *buf);
  4534.  int get_share_mode(int cnum,struct stat *sbuf,int *pid);
  4535.  void del_share_mode(int fnum);
  4536. @@ -679,6 +680,7 @@
  4537.  char *skip_string(char *buf,int n);
  4538.  BOOL is_locked(int fnum,int cnum,uint32 count,uint32 offset);
  4539.  int read_file(int fnum,char *data,int pos,int mincnt,int maxcnt,int timeout,BOOL exact);
  4540. +int write_file(int fnum,char *data,int n);
  4541.  BOOL do_lock(int fnum,int cnum,uint32 count,uint32 offset,int *eclass,uint32 *ecode);
  4542.  int seek_file(int fnum,int pos);
  4543.  BOOL do_unlock(int fnum,int cnum,uint32 count,uint32 offset,int *eclass,uint32 *ecode);
  4544. diff -u -r --new-file last-version/source/smbencrypt.c samba-1.9.16alpha1/source/smbencrypt.c
  4545. --- last-version/source/smbencrypt.c    Sun Nov  5 15:46:54 1995
  4546. +++ samba-1.9.16alpha1/source/smbencrypt.c    Thu Feb 29 00:12:08 1996
  4547. @@ -119,7 +119,7 @@
  4548.    StrnCpy((char *)p14,(char *)passwd,14);
  4549.  
  4550.    strupper((char *)p14);
  4551. -  E_P16(p14, p21);
  4552. +  E_P16(p14, p21); 
  4553.    E_P24(p21, c8, p24);
  4554.  }
  4555.  
  4556. diff -u -r --new-file last-version/source/smbtar samba-1.9.16alpha1/source/smbtar
  4557. --- last-version/source/smbtar    Thu Jun 29 17:58:36 1995
  4558. +++ samba-1.9.16alpha1/source/smbtar    Thu Feb 29 00:12:08 1996
  4559. @@ -1,87 +1,141 @@
  4560.  #!/bin/sh
  4561. -# 
  4562. -
  4563. -# edit this to show where your smbclient is
  4564. -SMBCLIENT="./smbclient"
  4565. +#
  4566. +# smbtar script - front end to smbclient
  4567. +#
  4568. +# Authors: Martin.Kraemer <Martin.Kraemer@mch.sni.de>
  4569. +#          and Ricky Poulten (ricky@logcam.co.uk)
  4570. +#
  4571. +# (May need to change shell to ksh for HPUX or OSF for better getopts)
  4572. +
  4573. +case $0 in
  4574. +    # when called by absolute path, assume smbclient is in the same directory
  4575. +    /*)
  4576. +    SMBCLIENT="`dirname $0`/smbclient";;
  4577. +    *)  # edit this to show where your smbclient is
  4578. +    SMBCLIENT="./smbclient";;
  4579. +esac
  4580.  
  4581. +# These are the default values. You could fill them in if you know what
  4582. +# you're doing, but beware: better not store a plain text password!
  4583.  server=""
  4584. -service=backup
  4585. +service="backup"            # Default: a service called "backup"
  4586.  password=""
  4587. -username=$LOGNAME
  4588. -verbose="/dev/null"
  4589. +username=$LOGNAME           # Default: same user name as in *nix
  4590. +verbose="2>/dev/null"        # Default: no echo to stdout
  4591.  log="-d 2"
  4592.  newer=""
  4593.  blocksize=""
  4594. -tarcmd="tar c"
  4595. -TF=${TAPE-tar.out}
  4596. +tarcmd="c"
  4597. +tarargs=""
  4598. +cdcmd="\\"
  4599. +tapefile=${TAPE-tar.out}
  4600. +
  4601. +Usage(){
  4602. +    ex=$1
  4603. +    shift
  4604. +echo >&2 "Usage: `basename $0` [<options>] [<include/exclude files>]
  4605. +Function: backup/restore a Windows PC directories to a local tape file
  4606. +Options:         (Description)                 (Default)
  4607. +  -r             Restore from tape file to PC  Save from PC to tapefile
  4608. +  -i             Incremental mode              Full backup mode
  4609. +  -v             Verbose mode: echo command    Don't echo anything
  4610. +  -s <server>    Specify PC Server             $server
  4611. +  -p <password>  Specify PC Password           $password
  4612. +  -x <share>     Specify PC Share              $service
  4613. +  -X             Exclude mode                  Include
  4614. +  -N <newer>     File for date comparison      `set -- $newer; echo $2`
  4615. +  -b <blocksize> Specify tape's blocksize      `set -- $blocksize; echo $2`
  4616. +  -d <dir>       Specify a directory in share  $cdcmd
  4617. +  -l <log>       Specify a Samba Log Level     `set -- $log; echo $2`
  4618. +  -u <user>      Specify User Name             $username
  4619. +  -t <tape>      Specify Tape device           $tapefile
  4620. +"
  4621. +  echo >&2 "$@"
  4622. +  exit $ex
  4623. +}
  4624.  
  4625. -USAGE=$0" [ -pxut ] -s server\n
  4626. -  -p password\n
  4627. -  -x service\n
  4628. -  -n newer\n
  4629. -  -i incremental\n
  4630. -  -b blocksize\n
  4631. -  -r restore\n
  4632. -  -l log\n
  4633. -  -u user\n
  4634. -  -r restore\n
  4635. -  -t tape"
  4636. -while getopts ril:b:n:vs:p:x:u:t: c; do
  4637. +while getopts rivl:b:d:N:s:p:x:u:Xt: c; do
  4638.    case $c in
  4639. -   r) tarcmd="tar x"
  4640. -      ;;
  4641. -   i) incremental="tarmode inc reset"
  4642. +   r) # [r]estore to Windows (instead of the default "Save from Windows")
  4643. +      tarcmd="x"
  4644.        ;;
  4645. -   l) log="-d $OPTARG"
  4646. +   i) # [i]ncremental
  4647. +      tarargs=${tarargs}g
  4648.        ;;
  4649. -   n) if [ -f $OPTARG ]; then 
  4650. -        newer="newer $OPTARG"
  4651. +   l) # specify [l]og file
  4652. +      log="-d $OPTARG"
  4653. +      case "$OPTARG" in
  4654. +    [0-9]*) ;;
  4655. +    *)      echo >&2 "$0: Error, log level not numeric: -l $OPTARG"
  4656. +        exit 1
  4657. +      esac
  4658. +      ;;
  4659. +   d) # specify [d]irectory to change to in server's share
  4660. +      cdcmd="$OPTARG"
  4661. +      ;;
  4662. +   N) # compare with a file, test if [n]ewer
  4663. +      if [ -f $OPTARG ]; then
  4664. +    newer=$OPTARG
  4665. +        tarargs=${tarargs}N
  4666.        else
  4667. -        echo $0: Warning, $OPTARG not found
  4668. +    echo >&2 $0: Warning, $OPTARG not found
  4669.        fi
  4670.        ;;
  4671. -   s) server=$OPTARG
  4672. -      ;;
  4673. -   b) blocksize="blocksize $OPTARG"
  4674. +   X) # Add exclude flag
  4675. +      tarargs=${tarargs}X
  4676.        ;;
  4677. -   p) password=$OPTARG
  4678. +   s) # specify [s]erver's share to connect to - this MUST be given.
  4679. +      server="$OPTARG"
  4680.        ;;
  4681. -   x) service=$OPTARG
  4682. +   b) # specify [b]locksize
  4683. +      blocksize="blocksize $OPTARG"
  4684. +      case "$OPTARG" in
  4685. +    [0-9]*) ;;
  4686. +    *)      echo >&2 "$0: Error, block size not numeric: -b $OPTARG"
  4687. +        exit 1
  4688. +      esac
  4689. +      tarargs=${tarargs}b
  4690. +      ;;
  4691. +   p) # specify [p]assword to use
  4692. +      password="$OPTARG"
  4693. +      ;;
  4694. +   x) # specify windows [s]hare to use
  4695. +      service="$OPTARG"
  4696. +      ;;
  4697. +   t) # specify [t]apefile on local host
  4698. +      tapefile="$OPTARG"
  4699.        ;;
  4700. -   t) TF=$OPTARG
  4701. +   u) # specify [u]sername for connection
  4702. +      username="$OPTARG"
  4703.        ;;
  4704. -   u) username=$OPTARG
  4705. +   v) # be [v]erbose and display what's going on
  4706. +      verbose=""
  4707.        ;;
  4708. -   v) verbose="/dev/tty"
  4709. -      ;;
  4710. -   \?) echo $USAGE
  4711. -       exit 2
  4712. +   '?') # any other switch
  4713. +       Usage 2 "Invalid switch specified - abort."
  4714.        ;;
  4715.    esac
  4716.  done
  4717. +
  4718.  shift `expr $OPTIND - 1`
  4719.  
  4720. -if [ $service = "" ]; then
  4721. -  echo $USAGE
  4722. -  exit 1
  4723. +if [ "$server" = "" ] || [ "$service" = "" ]; then
  4724. +  Usage 1 "No server or no service specified - abort."
  4725.  fi
  4726.  
  4727. -if [ -n $verbose ]; then
  4728. -      echo server is $server
  4729. -      echo service is $service
  4730. -      echo tar cmd is $tarcmd
  4731. -      echo password is $password
  4732. -      echo share is $service
  4733. -      echo tape is $TF
  4734. +# if the -v switch is set, the echo the current parameters
  4735. +if [ -z "$verbose" ]; then
  4736. +      echo "server    is $server"
  4737. +#     echo "share     is $service"
  4738. +      echo "share     is $service\\$cdcmd"
  4739. +      echo "tar args  is $tarargs"
  4740. +#     echo "password  is $password"  # passwords should never be sent to screen
  4741. +      echo "tape      is $tapefile"
  4742. +      echo "blocksize is $blocksize"
  4743.  fi
  4744.  
  4745. -(
  4746. -    echo "lowercase"
  4747. -    echo $newer
  4748. -    echo $blocksize
  4749. -    echo $incremental
  4750. -    echo $tarcmd $TF
  4751. -) | $SMBCLIENT "\\\\$server\\$service" $password -U $username -N $log > $verbose
  4752. +eval $SMBCLIENT "'\\\\$server\\$service'" "'$password'" -U "'$username'" \
  4753. +-E -N $log -D "'$cdcmd'" \
  4754. +-T${tarcmd}${tarargs} $blocksize $newer $tapefile $* $verbose
  4755. +
  4756.  
  4757. diff -u -r --new-file last-version/source/system.c samba-1.9.16alpha1/source/system.c
  4758. --- last-version/source/system.c    Mon Jan 15 13:12:05 1996
  4759. +++ samba-1.9.16alpha1/source/system.c    Sun Feb 18 17:47:10 1996
  4760. @@ -21,6 +21,8 @@
  4761.  
  4762.  #include "includes.h"
  4763.  
  4764. +extern int DEBUGLEVEL;
  4765. +
  4766.  /*
  4767.     The idea is that this file will eventually have wrappers around all
  4768.     important system calls in samba. The aim is twofold:
  4769. @@ -45,13 +47,9 @@
  4770.  
  4771.  #ifdef HAS_RDCHK
  4772.    r = rdchk(fd);
  4773. -#endif
  4774. -
  4775. -#ifdef HAS_TCRDCHK
  4776. +#elif defined(TCRDCHK)
  4777.    (void)ioctl(fd, TCRDCHK, &r);
  4778. -#endif
  4779. -
  4780. -#ifdef HAS_FIONREAD
  4781. +#else
  4782.    (void)ioctl(fd, FIONREAD, &r);
  4783.  #endif
  4784.  
  4785. @@ -96,7 +94,7 @@
  4786.    do {
  4787.      if (tval) memcpy((void *)&t2,(void *)tval,sizeof(t2));
  4788.      errno = 0;
  4789. -    selrtn = select(FD_SETSIZE,SELECT_CAST fds,NULL,NULL,tval?&t2:NULL);
  4790. +    selrtn = select(16,SELECT_CAST fds,NULL,NULL,tval?&t2:NULL);
  4791.    } while (selrtn<0 && errno == EINTR);
  4792.  
  4793.    return(selrtn);
  4794. diff -u -r --new-file last-version/source/trans2.c samba-1.9.16alpha1/source/trans2.c
  4795. --- last-version/source/trans2.c    Sun Dec  3 19:26:38 1995
  4796. +++ samba-1.9.16alpha1/source/trans2.c    Thu Feb 29 00:12:08 1996
  4797. @@ -54,6 +54,7 @@
  4798.    char *pp = params;
  4799.    char *pd = pdata;
  4800.    int params_sent_thistime, data_sent_thistime, total_sent_thistime;
  4801. +  int alignment_offset = 1;
  4802.  
  4803.    /* Initially set the wcnt area to be 10 - this is true for all
  4804.       trans2 replies */
  4805. @@ -68,13 +69,15 @@
  4806.      }
  4807.  
  4808.    /* Space is bufsize minus Netbios over TCP header minus SMB header */
  4809. -  useable_space = bufsize - (smb_buf(outbuf) - outbuf);
  4810. -  useable_space = MIN(useable_space, maxxmit);
  4811. +  /* The + 1 is to align the param and data bytes on an even byte
  4812. +     boundary. NT 4.0 Beta needs this to work correctly. */
  4813. +  useable_space = bufsize - ((smb_buf(outbuf)+alignment_offset) - outbuf);
  4814. +  useable_space = MIN(useable_space, maxxmit); /* XXX is this needed? correct? */
  4815.  
  4816.    while( params_to_send || data_to_send)
  4817.      {
  4818.        /* Calculate whether we will totally or partially fill this packet */
  4819. -      total_sent_thistime = params_to_send + data_to_send;
  4820. +      total_sent_thistime = params_to_send + data_to_send + alignment_offset;
  4821.        total_sent_thistime = MIN(total_sent_thistime, useable_space);
  4822.  
  4823.        set_message(outbuf, 10, total_sent_thistime, True);
  4824. @@ -100,7 +103,7 @@
  4825.           parameter bytes, however the first 4 bytes of outbuf are
  4826.           the Netbios over TCP header. Thus use smb_base() to subtract
  4827.           them from the calculation */
  4828. -      SSVAL(outbuf,smb_proff,(smb_buf(outbuf) - smb_base(outbuf)));
  4829. +      SSVAL(outbuf,smb_proff,((smb_buf(outbuf)+alignment_offset) - smb_base(outbuf)));
  4830.        /* Absolute displacement of param bytes sent in this packet */
  4831.        SSVAL(outbuf,smb_prdisp,pp - params);
  4832.      }
  4833. @@ -113,16 +116,17 @@
  4834.      } else {
  4835.        /* The offset of the data bytes is the offset of the
  4836.           parameter bytes plus the number of parameters being sent this time */
  4837. -      SSVAL(outbuf,smb_droff,(smb_buf(outbuf) - smb_base(outbuf)) + params_sent_thistime);
  4838. +      SSVAL(outbuf,smb_droff,((smb_buf(outbuf)+alignment_offset) - 
  4839. +                  smb_base(outbuf)) + params_sent_thistime);
  4840.        SSVAL(outbuf,smb_drdisp, pd - pdata);
  4841.      }
  4842.  
  4843.        /* Copy the param bytes into the packet */
  4844.        if(params_sent_thistime)
  4845. -    memcpy(smb_buf(outbuf),pp,params_sent_thistime);
  4846. +    memcpy((smb_buf(outbuf)+alignment_offset),pp,params_sent_thistime);
  4847.        /* Copy in the data bytes */
  4848.        if(data_sent_thistime)
  4849. -    memcpy(smb_buf(outbuf)+params_sent_thistime,pd,data_sent_thistime);
  4850. +    memcpy(smb_buf(outbuf)+alignment_offset+params_sent_thistime,pd,data_sent_thistime);
  4851.  
  4852.        DEBUG(9,("t2_rep: params_sent_thistime = %d, data_sent_thistime = %d, useable_space = %d\n",
  4853.             params_sent_thistime, data_sent_thistime, useable_space));
  4854. @@ -194,7 +198,7 @@
  4855.    if (!check_name(fname,cnum))
  4856.      return(UNIXERROR(ERRDOS,ERRnoaccess));
  4857.  
  4858. -  unixmode = unix_mode(cnum,open_attr);
  4859. +  unixmode = unix_mode(cnum,open_attr | aARCH);
  4860.        
  4861.        
  4862.    open_file_shared(fnum,cnum,fname,open_mode,open_ofun,unixmode,
  4863. @@ -258,7 +262,7 @@
  4864.    char *p, *pdata = *ppdata;
  4865.    int reskey=0, prev_dirpos=0;
  4866.    int mode=0;
  4867. -  uint32 size=0;
  4868. +  uint32 size=0,len;
  4869.    uint32 mdate=0, adate=0, cdate=0;
  4870.    char *name_ptr;
  4871.    BOOL isrootdir = (strequal(Connections[cnum].dirpath,"./") ||
  4872. @@ -422,7 +426,9 @@
  4873.  
  4874.      case SMB_FIND_FILE_BOTH_DIRECTORY_INFO:
  4875.        was_8_3 = is_8_3(fname);
  4876. -      SIVAL(p,0,94+strlen(fname)); p += 4;
  4877. +      len = 94+strlen(fname);
  4878. +      len = (len + 3) & ~3;
  4879. +      SIVAL(p,0,len); p += 4;
  4880.        SIVAL(p,0,reskey); p += 4;
  4881.        put_long_date(p,cdate); p += 8;
  4882.        put_long_date(p,adate); p += 8;
  4883. @@ -439,7 +445,8 @@
  4884.  #else 
  4885.      strcpy(p+2,fname);
  4886.  #endif
  4887. -    name_map_mangle(p+2,True,SNUM(cnum));
  4888. +    if (!name_map_mangle(p+2,True,SNUM(cnum)))
  4889. +      (p+2)[12] = 0;
  4890.        } else
  4891.      *(p+2) = 0;
  4892.        strupper(p+2);
  4893. @@ -447,10 +454,13 @@
  4894.        p += 2 + 24;
  4895.        /* name_ptr = p;  */
  4896.        strcpy(p,fname); p += strlen(p);
  4897. +      p = pdata + len;
  4898.        break;
  4899.  
  4900.      case SMB_FIND_FILE_DIRECTORY_INFO:
  4901. -      SIVAL(p,0,64+strlen(fname)); p += 4;
  4902. +      len = 64+strlen(fname);
  4903. +      len = (len + 3) & ~3;
  4904. +      SIVAL(p,0,len); p += 4;
  4905.        SIVAL(p,0,reskey); p += 4;
  4906.        put_long_date(p,cdate); p += 8;
  4907.        put_long_date(p,adate); p += 8;
  4908. @@ -460,12 +470,15 @@
  4909.        SIVAL(p,0,size); p += 8;
  4910.        SIVAL(p,0,mode); p += 4;
  4911.        SIVAL(p,0,strlen(fname)); p += 4;
  4912. -      strcpy(p,fname); p += strlen(p);
  4913. +      strcpy(p,fname);
  4914. +      p = pdata + len;
  4915.        break;
  4916.        
  4917.        
  4918.      case SMB_FIND_FILE_FULL_DIRECTORY_INFO:
  4919. -      SIVAL(p,0,68+strlen(fname)); p += 4;
  4920. +      len = 68+strlen(fname);
  4921. +      len = (len + 3) & ~3;
  4922. +      SIVAL(p,0,len); p += 4;
  4923.        SIVAL(p,0,reskey); p += 4;
  4924.        put_long_date(p,cdate); p += 8;
  4925.        put_long_date(p,adate); p += 8;
  4926. @@ -476,14 +489,18 @@
  4927.        SIVAL(p,0,mode); p += 4;
  4928.        SIVAL(p,0,strlen(fname)); p += 4;
  4929.        SIVAL(p,0,0); p += 4;
  4930. -      strcpy(p,fname); p += strlen(p);
  4931. +      strcpy(p,fname);
  4932. +      p = pdata + len;
  4933.        break;
  4934.  
  4935.      case SMB_FIND_FILE_NAMES_INFO:
  4936. -      SIVAL(p,0,12+strlen(fname)); p += 4;
  4937. +      len = 12+strlen(fname);
  4938. +      len = (len + 3) & ~3;
  4939. +      SIVAL(p,0,len); p += 4;
  4940.        SIVAL(p,0,reskey); p += 4;
  4941.        SIVAL(p,0,strlen(fname)); p += 4;
  4942. -      strcpy(p,fname); p += strlen(p);
  4943. +      strcpy(p,fname);
  4944. +      p = pdata + len;
  4945.        break;
  4946.  
  4947.      default:      
  4948. @@ -1293,7 +1310,7 @@
  4949.      if(sys_utime(fname, &tvs)!=0)
  4950.        return(ERROR(ERRDOS,ERRnoaccess));
  4951.    }
  4952. -  if(mode != dos_mode(cnum,fname,&st) && dos_chmod(cnum,fname,mode)) {
  4953. +  if(mode != dos_mode(cnum,fname,&st) && dos_chmod(cnum,fname,mode,NULL)) {
  4954.      DEBUG(2,("chmod of %s failed (%s)\n", fname, strerror(errno)));
  4955.      return(ERROR(ERRDOS,ERRnoaccess));
  4956.    }
  4957. @@ -1541,7 +1558,7 @@
  4958.        receive_smb(Client,inbuf, 0);
  4959.        
  4960.        /* Ensure this is still a trans2 packet (sanity check) */
  4961. -      if(CVAL(inbuf, smb_com) != SMBtrans2)
  4962. +      if(CVAL(inbuf, smb_com) != SMBtranss2)
  4963.          {
  4964.            outsize = set_message(outbuf,0,0,True);
  4965.            DEBUG(2,("Invalid secondary trans2 packet\n"));
  4966. diff -u -r --new-file last-version/source/util.c samba-1.9.16alpha1/source/util.c
  4967. --- last-version/source/util.c    Tue Jan 16 10:14:44 1996
  4968. +++ samba-1.9.16alpha1/source/util.c    Thu Feb 29 00:12:08 1996
  4969. @@ -536,6 +536,8 @@
  4970.  }
  4971.  
  4972.  
  4973. +static char *last_ptr=NULL;
  4974. +
  4975.  /****************************************************************************
  4976.    Get the next token from a string, return False if none found
  4977.    handles double-quotes. 
  4978. @@ -544,7 +546,6 @@
  4979.  ****************************************************************************/
  4980.  BOOL next_token(char **ptr,char *buff,char *sep)
  4981.  {
  4982. -  static char *last_ptr=NULL;
  4983.    char *s;
  4984.    BOOL quoted;
  4985.  
  4986. @@ -578,6 +579,44 @@
  4987.    return(True);
  4988.  }
  4989.  
  4990. +/****************************************************************************
  4991. +Convert list of tokens to array; dependent on above routine.
  4992. +Uses last_ptr from above - bit of a hack.
  4993. +****************************************************************************/
  4994. +char **toktocliplist(int *ctok, char *sep)
  4995. +{
  4996. +  char *s=last_ptr;
  4997. +  int ictok=0;
  4998. +  char **ret, **iret;
  4999. +
  5000. +  if (!sep) sep = " \t\n\r";
  5001. +
  5002. +  while(*s && strchr(sep,*s)) s++;
  5003. +
  5004. +  /* nothing left? */
  5005. +  if (!*s) return(NULL);
  5006. +
  5007. +  do {
  5008. +    ictok++;
  5009. +    while(*s && (!strchr(sep,*s))) s++;
  5010. +    while(*s && strchr(sep,*s)) *s++=0;
  5011. +  } while(*s);
  5012. +
  5013. +  *ctok=ictok;
  5014. +  s=last_ptr;
  5015. +
  5016. +  if (!(ret=iret=malloc(ictok*sizeof(char *)))) return NULL;
  5017. +  
  5018. +  while(ictok--) {    
  5019. +    *iret++=s;
  5020. +    while(*s++);
  5021. +    while(!*s) s++;
  5022. +  }
  5023. +
  5024. +  return ret;
  5025. +}
  5026. +
  5027. +#ifndef HAVE_MEMMOVE
  5028.  /*******************************************************************
  5029.  safely copies memory, ensuring no overlap problems.
  5030.  this is only used if the machine does not have it's own memmove().
  5031. @@ -635,6 +674,7 @@
  5032.      }
  5033.    return(dest);
  5034.  }
  5035. +#endif
  5036.  
  5037.  
  5038.  /****************************************************************************
  5039. @@ -1196,6 +1236,7 @@
  5040.  ********************************************************************/
  5041.  BOOL strequal(char *s1,char *s2)
  5042.  {
  5043. +  if (s1 == s2) return(True);
  5044.    if (!s1 || !s2) return(False);
  5045.    
  5046.    return(StrCaseCmp(s1,s2)==0);
  5047. @@ -1206,6 +1247,7 @@
  5048.    ******************************************************************/
  5049.  BOOL strnequal(char *s1,char *s2,int n)
  5050.  {
  5051. +  if (s1 == s2) return(True);
  5052.    if (!s1 || !s2 || !n) return(False);
  5053.    
  5054.    return(StrnCaseCmp(s1,s2,n)==0);
  5055. @@ -1216,6 +1258,7 @@
  5056.  ********************************************************************/
  5057.  BOOL strcsequal(char *s1,char *s2)
  5058.  {
  5059. +  if (s1 == s2) return(True);
  5060.    if (!s1 || !s2) return(False);
  5061.    
  5062.    return(strcmp(s1,s2)==0);
  5063. @@ -1904,6 +1947,9 @@
  5064.    if ((*mext == 0) && doext && !hasdot)
  5065.      strcpy(mext,"???");
  5066.  
  5067. +  if (strequal(mbeg,"*") && *mext==0) 
  5068. +    strcpy(mext,"*");
  5069. +
  5070.    /* expand *'s */
  5071.    expand_one(mbeg,8);
  5072.    if (*mext)
  5073. @@ -2149,6 +2195,7 @@
  5074.    int readret;
  5075.    int nread = 0;
  5076.    struct timeval timeout, tval1, tval2, tvaldiff;
  5077. +  int error_limit = 5;
  5078.  
  5079.    /* just checking .... */
  5080.    if (maxcnt <= 0) return(0);
  5081. @@ -2201,61 +2248,60 @@
  5082.    nread = 0; /* Number of bytes we have read */
  5083.  
  5084.    for(;;) 
  5085. -    {
  5086. -      
  5087. +    {      
  5088.        FD_ZERO(&fds);
  5089.        FD_SET(fd,&fds);
  5090.        
  5091.        selrtn = sys_select(&fds,&timeout);
  5092.        
  5093.        /* Check if error */
  5094. -      if(selrtn == -1)
  5095. -    {
  5096. -      errno = EBADF;
  5097. -      return -1;
  5098. -    }
  5099. +      if(selrtn == -1) {
  5100. +    errno = EBADF;
  5101. +    return -1;
  5102. +      }
  5103.        
  5104.        /* Did we timeout ? */
  5105. -      if (selrtn == 0 ) {
  5106. -     if (nread < mincnt) return -1;
  5107. +      if (selrtn == 0) {
  5108. +    if (nread < mincnt) return -1;
  5109.      break; /* Yes */
  5110.        }
  5111.        
  5112. -      readret = read( fd, buf+nread, maxcnt-nread);
  5113. -      if(readret <= 0)
  5114. -    {
  5115. -      /* force a particular error number for
  5116. -         portability */
  5117. -      errno = EBADF;
  5118. -      return -1;
  5119. -    }
  5120. +      readret = read(fd, buf+nread, maxcnt-nread);
  5121. +      if (readret == 0 && nread < mincnt) {
  5122. +    /* error_limit should not really be needed, but some systems
  5123. +       do strange things ...  I don't want to just continue
  5124. +       indefinately in case we get an infinite loop */
  5125. +    if (error_limit--) continue;
  5126. +    return(-1);
  5127. +      }
  5128.  
  5129. -      if (readret == 0)
  5130. -    break;
  5131. +      if (readret < 0) {
  5132. +    /* force a particular error number for
  5133. +       portability */
  5134. +    DEBUG(5,("read gave error %s\n",strerror(errno)));
  5135. +    errno = EBADF;
  5136. +    return -1;
  5137. +      }
  5138.        
  5139.        nread += readret;
  5140.        
  5141.        /* If we have read more than mincnt then return */
  5142. -      if( nread >= mincnt )
  5143. +      if (nread >= mincnt)
  5144.      break;
  5145.  
  5146.        /* We need to do another select - but first reduce the
  5147.       time_out by the amount of time already elapsed - if
  5148.       this is less than zero then return */
  5149. -      if (exact)
  5150. -    {
  5151. -      GetTimeOfDay( &tval2);
  5152. -      (void)tval_sub( &tvaldiff, &tval2, &tval1);
  5153. +      if (exact) {
  5154. +    GetTimeOfDay(&tval2);
  5155. +    (void)tval_sub( &tvaldiff, &tval2, &tval1);
  5156.        
  5157. -      if( tval_sub( &timeout, &timeout, &tvaldiff) <= 0) 
  5158. -        {
  5159. -          /* We timed out */
  5160. -          break;
  5161. -        }
  5162. -    }
  5163. +    if (tval_sub(&timeout, &timeout, &tvaldiff) <= 0) 
  5164. +      break; /* We timed out */
  5165. +      }
  5166.        
  5167.        /* Save the time of day as we need to do the select 
  5168. -     again (saves a system call)*/
  5169. +     again (saves a system call) */
  5170.        tval1 = tval2;
  5171.      }
  5172.  
  5173. @@ -3948,21 +3994,32 @@
  5174.      sprintf(pidstr,"%d",(int)getpid());
  5175.      string_sub(s,"%d",pidstr);
  5176.    }
  5177. +
  5178. +  if (!strchr(s,'%')) return;
  5179. +
  5180. +  {
  5181. +    struct passwd *pass = Get_Pwnam(sesssetup_user,False);
  5182. +    if (pass) {
  5183. +      string_sub(s,"%G",gidtoname(pass->pw_gid));
  5184. +    }
  5185. +  }
  5186.  }
  5187.  
  5188.  
  5189.  /*******************************************************************
  5190.  write a string in unicoode format
  5191.  ********************************************************************/
  5192. -void PutUniCode(char *dst,char *src)
  5193. +int PutUniCode(char *dst,char *src)
  5194.  {
  5195. +  int ret = 0;
  5196.    while (*src) {
  5197. -    dst[0] = src[0];
  5198. -    dst[1] = 0;    
  5199. -    dst += 2;
  5200. +    dst[ret++] = src[0];
  5201. +    dst[ret++] = 0;    
  5202.      src++;
  5203.    }
  5204. -  dst[0] = dst[1] = 0;
  5205. +  dst[ret++]=0;
  5206. +  dst[ret++]=0;
  5207. +  return(ret);
  5208.  }
  5209.  
  5210.  
  5211. @@ -4084,7 +4141,7 @@
  5212.  ********************************************************************/
  5213.  char *uidtoname(int uid)
  5214.  {
  5215. -  static char name[20];
  5216. +  static char name[40];
  5217.    struct passwd *pass = getpwuid(uid);
  5218.    if (pass) return(pass->pw_name);
  5219.    sprintf(name,"%d",uid);
  5220. @@ -4096,7 +4153,7 @@
  5221.  ********************************************************************/
  5222.  char *gidtoname(int gid)
  5223.  {
  5224. -  static char name[20];
  5225. +  static char name[40];
  5226.    struct group *grp = getgrgid(gid);
  5227.    if (grp) return(grp->gr_name);
  5228.    sprintf(name,"%d",gid);
  5229. diff -u -r --new-file last-version/source/version.h samba-1.9.16alpha1/source/version.h
  5230. --- last-version/source/version.h    Tue Jan 16 20:37:41 1996
  5231. +++ samba-1.9.16alpha1/source/version.h    Thu Feb 29 00:23:15 1996
  5232. @@ -1 +1 @@
  5233. -#define VERSION "1.9.15p8"
  5234. +#define VERSION "1.9.16alpha1"
  5235.